PowerShell批量安装msi后辍软件的方法
时间:2021-08-13 07:36:35|栏目:|点击: 次
如果你要安装的MSI包不止一个,可不能使用Invoke-Item,否则PowerShell不会等待前一个安装包安装完毕,就已经运行下一个安装包了。
如果在批处理中,我们可能会使用msiexec file.msi /wait。在PowerShell中也可以借助于msiexec。
先就这些安装包路径存储到数组中吧:
复制代码 代码如下:
$msi = @("c:\file1.msi", "c:\file2.msi", "c:\file2.msi")
然后使用Start-Process的-wait参数,等到前一个安装程序运行完毕后,再启动下一个:
复制代码 代码如下:
foreach($_ in $msi)
{
Start-Process -FilePath msiexec -ArgumentList /i, $_, /qn -Wait
}
{
Start-Process -FilePath msiexec -ArgumentList /i, $_, /qn -Wait
}
另外一个办法是把输出结果重定向一些Null,也能保证程序等待安装完成:
复制代码 代码如下:
foreach($_ in $msi)
{
msiexec /i $_ /qn | out-null
}
{
msiexec /i $_ /qn | out-null
}
文章出处:http://www.pstips.net/install-multiple-msi-using-powershell.html
上一篇:Linux Centos下使用脚本安装Docker的方法
栏 目:
下一篇:docker 容器上编译 go 程序提示找不到文件问题
本文地址:http://www.codeinn.net/misctech/166569.html






