无法通过PowerShell脚本安装Microsoft Update(Hotfix)-MSU
我正在尝试通过以下PowerShell脚本安装MSU,但没有安装。我不知道Powershell脚本。请有人给我最佳修改此脚本的方法。我期待听到。
Start-Process "C:\Installer\windows10.0-kb4520062-x64_9f2a827f11f945d19bd26de6f113f611a38bb8a1.msu" -ArgumentList "/quiet /norestart"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了能够将参数传递到通过
start-process
,(可能是定位暗示的)-filePath
参数必须是一个true 可执行 /em>,不仅是 document ,这是.msu
文件的内容。因此,您必须将
.msu
文件注册以通过显式处理-filepath
,即wusa的可执行文件。 exe
(注意/quet/norestart
在-argumentList
参数的结尾处):注意:
为了等待安装完成,添加
-Wait
Switch。另外检查该过程的退出代码以确定安装是否成功,请添加
-PassThru
Switch,在变量中捕获所得的Process-Info对象,然后检查其.exitCode
属性。但是,有一个技巧简化了上述:管道
wusa.exe
call to写入输出
,它迫使其同步执行(作为GUI-Subsystem应用程序,wusa.exe
否则会异步运行),还将其退出代码记录在自动$ $ lastExitCode
变量:In order to be able to pass arguments to a process launched via
Start-Process
, the (possibly positionally implied)-FilePath
argument must be a true executable, not just a document, which is what a.msu
file is.Therefore, you must pass the executable that
.msu
files are registered to be processed by explicitly to-FilePath
, which iswusa.exe
(note the/quiet /norestart
at the end of the-ArgumentList
argument):Note:
In order to wait for the installation to finish, add the
-Wait
switch.To additionally check the process' exit code in order to determine whether the installation succeeded, add the
-PassThru
switch, capture the resulting process-info object in a variable, and then check its.ExitCode
property.However, there is a trick that simplifies the above: pipe the
wusa.exe
call toWrite-Output
, which forces it to execute synchronously (as a GUI-subsystem application,wusa.exe
would otherwise run asynchronously) and also records its exit code in the automatic$LASTEXITCODE
variable: