Get-Url http://dl.google.com/chrome/install/375.126/chrome_installer.exe c:\temp\chrome_installer.exe;
c:\temp\chrome_installer.exe /silent /install;
Run Code Online (Sandbox Code Playgroud)
我有以下几点。但是我也喜欢在chrome之后安装其他应用程序。这是正确的方法还是我会遇到问题,因为Powershell不知道何时完成安装以及何时启动另一安装?
我应该改走MSI路线吗?
您可以使用Start-Process该-Wait参数,大多数安装文件将使用此方法,但是如果安装程序打开其他文件并自行关闭,则此方法将不起作用(因为PowerShell仅在等待安装程序关闭)
我没有Get-Url函数来测试以下代码,但它应该可以工作:
第一个Start-Process将启动Chrome的安装程序,然后等待窗口关闭,然后再运行第二个Start-Process。
Get-Url http://dl.google.com/chrome/install/375.126/chrome_installer.exe c:\temp\chrome_installer.exe
Start-Process -FilePath 'c:\temp\chrome_installer.exe' -ArgumentList '/silent', '/install' -Wait
Start-Process -FilePath 'C:\temp\DifferentProgram.exe' -ArgumentList '/argument' -Wait
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12396 次 |
| 最近记录: |