使用与 /Q开关的启动过程安装MSI



我想安装带有/q开关的MSI,我在线查看,示例没有/q Switch,我一直遇到错误。

我需要类似的东西:

$WorkingDirectory = (Split-Path $myinvocation.mycommand.path -Parent)
Start-Process -FilePath msiexec /i "$WorkingDirectoryLAPS.x64.msi" -ArgumentList /q

不要打扰Start-Process。使用呼叫操作员:

& msiexec.exe /i "$WorkingDirectoryLAPS.x64.msi" /q

将整个命令放在括号中

示例(Python MSI):

Start-Process msiexec.exe -Wait -ArgumentList "/I $($LocalPython.FullName) /passive ALLUSERS=1 ADDLOCAL=Extensions" 

/q

替换/passive

并非所有安装程序都是相同的。要找到用于.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
$path="C:Datinstall.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$windowstemp" -Force -Recurse 
    $newProc=([WMICLASS]"\$_rootcimv2:win32_Process").Create("C:windowstemp$packageinstall")
    If ($newProc.ReturnValue -eq 0) {
        Write-Host $_ $newProc.ProcessId
    } else {
        write-host $_ Process create failed with $newProc.ReturnValue
    }
}

最新更新