msi Generator-下载自定义为MSI,我需要下载和执行。
我可以下载并指定保存的文件名,但我无法通过。
因此,此特殊URL创建一个自定义MSI文件以下载,例如 Installer_t493ht.msi
(每次都会随机部分发生变化(。我正在尝试使用PowerShell将此文件下载到特定目录,将文件名分配给变量,然后执行。
到目前为止,我所拥有的是:
$url = "https://UrlThatGeneratesRandomlyNamedMSI"
$output = "c:SaveToThisDirectory"
Import-Module BitsTransfer
$job += Start-BitsTransfer -Source $url -Destination $output
while ($job | Where-Object {$job.JobState -eq "Transferring"}) {
Sleep -Seconds 1
}
Start-Process msiexec.exe -Wait -ArgumentList '/I /qn $output/$RandomName.msi REBOOT=ReallySuppress'
只需添加类似的内容:
$msiFile = Get-Item -Path "$outputInstaller_*.msi"
执行该操作(确保您使用双引号,因此variabele被扩展(:
Start-Process msiexec.exe -Wait -ArgumentList "/I /qn $($msiFile.FullName) REBOOT=ReallySuppress"