我正在尝试在用户数据中使用PowerShell自动安装Chrome以及其他几个任务。但是,镀铬的安装失败,因为它需要在高架模式下进行powershell。
以下是我的代码的片段:
<powershell>
#Change TimeZone
C:WindowsSystem32tzutil /s "AUS Eastern Standard Time"
#Install Chrome
$Path = $env:TEMP;
$Installer = "chrome_installer.exe";
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path$Installer;
Start-Process -FilePath $Path$Installer -ArgumentList "/silent /install" -Verb RunAs -Wait;
Remove-Item $Path$Installer
#Set Chrome as default browser
$chromePath = "${Env:ProgramFiles(x86)}GoogleChromeApplication"
$chromeApp = "chrome.exe"
$chromeCommandArgs = "--make-default-browser"
& "$chromePath$chromeApp" $chromeCommandArgs
</powershell>
有人可以建议,如何实现?
预先感谢。
我能够通过添加" set-location" c: windows system32"作为第一行。因此,我的脚本看起来如下:
<powershell>
Set-Location "C:Windowssystem32"
#Change TimeZone
C:WindowsSystem32tzutil /s "AUS Eastern Standard Time"
#Install Chrome
$Path = $env:TEMP;
$Installer = "chrome_installer.exe";
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path$Installer;
Start-Process -FilePath $Path$Installer -ArgumentList "/silent /install" -Verb RunAs -Wait;
Remove-Item $Path$Installer
#Set Chrome as default browser
$chromePath = "${Env:ProgramFiles(x86)}GoogleChromeApplication"
$chromeApp = "chrome.exe"
$chromeCommandArgs = "--make-default-browser"
& "$chromePath$chromeApp" $chromeCommandArgs
</powershell>