我想安装带有/q
开关的msi,我在线查看,示例没有/q
开关,我一直收到错误。
我需要类似的东西:
$WorkingDirectory = (Split-Path $myinvocation.mycommand.path -Parent)
Start-Process -FilePath msiexec /i "$WorkingDirectory\LAPS.x64.msi" -ArgumentList /q
答案 0 :(得分:2)
不要打扰Start-Process
。使用call operator:
& msiexec.exe /i "$WorkingDirectory\LAPS.x64.msi" /q
答案 1 :(得分:0)
将整个命令放在括号中
示例(Python msi):
Start-Process msiexec.exe -Wait -ArgumentList "/I $($LocalPython.FullName) /passive ALLUSERS=1 ADDLOCAL=Extensions"
将/passive
替换为/q
答案 2 :(得分:0)
并非所有安装程序都相同。要查找.msi的安装程序开关,请使用:
.\LAPS.x64.msi /?
.\LAPS.x64.msi -?
我还会将msi
路径存储在变量中,并使用ArrayList
作为参数,这样的东西在我的脚本中对我有用:
# Path to .msi
$msiPath= 'C:\LAPS.x64.msi'
# Define arguments
[System.Collections.ArrayList]$arguments =
@("/i `"$msiPath`"",
"/quiet")
# Start installation
Start-Process -FilePath msiexec.exe -ArgumentList "$arguments" -Wait -NoNewWindow
答案 3 :(得分:-1)
$path="C:\Dat\install.msi"
$parameters="/q"
$packageinstall=(split-path $path -leaf) + ' ' + $parameters
write-host $packageinstall
$computers = get-content c:\com.txt
$computers | where{test-connection $_ -quiet -count 1} | ForEach-Object {
copy-item $path "\\$_\c$\windows\temp" -Force -Recurse
$newProc=([WMICLASS]"\\$_\root\cimv2:win32_Process").Create("C:\windows\temp\$packageinstall")
If ($newProc.ReturnValue -eq 0) {
Write-Host $_ $newProc.ProcessId
} else {
write-host $_ Process create failed with $newProc.ReturnValue
}
}