简体   繁体   English

使用 Powershell/Batch 命令卸载 MS Office 更新(知识库文章)

[英]Uninstalling MS Office Update ( KB Article ) using Powershell/ Batch Command

Is there a clean way to uninstall MS Word KB Article using Batch/ PowerShell command?是否有使用 Batch/PowerShell 命令卸载 MS Word KB 文章的干净方法?

Background:背景:

I've been trying to uninstall one KB Article (KB4475558) MS Word 2013. As a part of solution to manual team, who wants to uninstall all newly installed KB articles.我一直在尝试卸载一篇 KB 文章 (KB4475558) MS Word 2013。作为手动团队解决方案的一部分,他们想要卸载所有新安装的 KB 文章。 I'm successful in trying to install multiple KB articles.我成功地尝试安装多篇知识库文章。 But uninstalling has been quiet tricky.但是卸载一直很棘手。

So far tried,到目前为止尝试过,

Approach 1: wusa /uninstall /KB:4475558 wusa.exe /uninstall /kb:4475558 /norestart /quiet ---- It gives "This Action is Only Valid for Products That are Currently Installed" Error.方法一: wusa /uninstall /KB:4475558 wusa.exe /uninstall /kb:4475558 /norestart /quiet ----它给出“此操作仅对当前安装的产品有效”错误。

Approach 2 : Using GUID方法 2:使用 GUID

Msiexec /I {90150000-006E-0401-1000-0000000FF1CE} MSIPATCHREMOVE={80BC2A33-0ADF-4731-AC75-046BA9B6B7AF} /qb ---- It gives "This Action is Only Valid for Products That are Currently Installed" Error. Msiexec /I {90150000-006E-0401-1000-0000000FF1CE} MSIPATCHREMOVE={80BC2A33-0ADF-4731-AC75-046BA9B6B7AF} /qb ----它给出“此产品操作仅适用于安装”的错误。

Approach 3:方法三:

using Microsoft.Update.Searcher via link below,通过以下链接使用 Microsoft.Update.Searcher,

PowerShell: How to find and uninstall a MS Office Update PowerShell:如何查找和卸载 MS Office 更新

-- Doesn't work. ——没用。

Can you please help me on these questions:你能帮我解决这些问题吗:

1: I have manually installed those KB Articles, I'm able to uninstall it manually: But through scripts, it shows the above error. 1:我已经手动安装了那些知识库文章,我可以手动卸载它:但是通过脚本,它显示了上述错误。 Why is it so?为什么会这样?

2: Any other approach I might be missing? 2:我可能会遗漏任何其他方法吗?

Note : MS Office is not installed only MS word and Share point and there is no Trail version available in my machine.注意:MS Office 不只安装 MS word 和 Share point,我的机器上没有可用的 Trail 版本。 I also tried rebooting the machine once, but no avail.我也试过重新启动机器一次,但无济于事。

Any help would be greatly helpful !任何帮助都会非常有帮助! Thanks谢谢

Have you tried using a to parse the uninstall string from the registry uninstall key?您是否尝试过使用来解析注册表卸载键中的卸载字符串? I wouldn't usually recommend this method, but it may be better than nothing.我通常不会推荐这种方法,但它可能总比没有好。

@(For /F "Delims=" %%G In (
    '^""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "(KB4475558)" /D 2^>NUL^|Find "{"^"'
)Do @For /F "Tokens=2*" %%H In ('^""%__AppDir__%reg.exe" Query "%%G" /V "UninstallString" 2^>NUL^"')Do @Echo(%%I)&Pause

If you're satisfied with the results, you could modify the code to try uninstalling it, (it is likely that you'll need to run the script or command 'As administrator') :如果您对结果感到满意,您可以修改代码以尝试卸载它, (您可能需要以“管理员身份”运行脚本或命令)

From a :

@For /F "Delims=" %%G In (
    '^""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "(KB4475558)" /D 2^>NUL^|Find "{"^"'
)Do @For /F "Tokens=2*" %%H In ('^""%__AppDir__%reg.exe" Query "%%G" /V "UninstallString" 2^>NUL^"')Do @%%I

or from :或从

For /F "Delims=" %G In ('""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "KB4475558" /D 2>NUL|Find "{""')Do @For /F "Tokens=2*" %H In ('""%__AppDir__%reg.exe" Query "%G" /V "UninstallString" 2>NUL"')Do @Echo(%I

If you were trying to do it for all KB updates for your office products, something like this may get you close:如果您尝试为办公产品的所有 KB 更新执行此操作,则类似以下内容可能会让您感到困惑:

@(For /F "Delims=" %%G In (
    '^""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "0FF1CE}_Office" /K 2^>NUL^|Find "{"^"'
)Do @For /F "Tokens=2*" %%H In ('^""%__AppDir__%reg.exe" Query "%%G" /V "UninstallString" 2^>NUL^"')Do @Echo(%%I)&Pause

If you're satisfied with the results, you could modify the code to try uninstalling it, (it is likely that you'll need to run the script or command 'As administrator') :如果您对结果感到满意,您可以修改代码以尝试卸载它, (您可能需要以“管理员身份”运行脚本或命令)

From a :

@(For /F "Delims=" %%G In (
    '^""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "0FF1CE}_Office" /K 2^>NUL^|Find "{"^"'
)Do @For /F "Tokens=2*" %%H In ('^""%__AppDir__%reg.exe" Query "%%G" /V "UninstallString" 2^>NUL^"')Do @Echo(%%I)&Pause

or from :或从

For /F "Delims=" %G In ('""%__AppDir__%reg.exe" Query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /S /F "0FF1CE}_Office" /K 2>NUL|Find "{""')Do @For /F "Tokens=2*" %H In ('""%__AppDir__%reg.exe" Query "%G" /V "UninstallString" 2>NUL"')Do @%I

Please note that the examples above are only parsing the registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall .请注意,上面的示例仅解析注册表项HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall There may be other locations, such as HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall holding information your require too.可能还有其他位置,例如HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall也包含您需要的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM