wmic卸载程序命令_使用WMIC命令行卸载软件

wmic卸载程序命令

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the same question.

最近,我在我经常访问的IT论坛中回答了很多这样的问题。 提出的问题通常类似于“我们已安装软件X,并且由于原因Y需要将其卸载”或类似问题的某些其他变体。

Now every administrator knows about uninstalling software from the Add/Remove Programs (or Programs and Features) tab in Control Panel.  This may work well if you have to uninstall from just a handful of computers, but what about if you are responsible for managing hundreds or thousands of computers?

现在,每个管理员都可以通过“控制面板”中的“添加/删除程序”(或“程序和功能”)选项卡了解有关卸载软件的信息。 如果您只需要从几台计算机上卸载,这可能会很好地工作,但是如果您负责管理数百台或数千台计算机,那又如何呢?

MsiExec / GUID方法
(The MsiExec / GUID Method
)

我经常推荐的一个答案是使用注册表卸载字符串,如下所述: Uninstall Registry Key卸载注册表项 http://msdn.microsoft.com/en-us/library/aa372105(VS.85).aspx http://msdn.microsoft.com/zh-CN/library/aa372105(VS.85).aspx

Basically, you open up RegEdit, navigate to

基本上,您打开RegEdit,导航到

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

HKEY_LOCAL_MACHINE \ Softwar e \ Microsof t \ Windows \ 当前版本 sion \ Unins

and look around for an entry matching the software you want to uninstall.

并查找与您要卸载的软件匹配的条目。

Once found, the registry key should have an UninstallString entry that should contain the MSIEXEC command that uses the GUID of the program to uninstall it.

一旦找到,注册表项应具有一个UninstallString条目,该条目应包含使用程序的GUID来卸载它的MSIEXEC命令。

I have used this many times in the past and this method does work to get software uninstalled. I do have some issues with it however, the first being that the GUID method is not very user friendly. Looking at the following GUID for Office 2007 Professional {90120000-0011-0000-0000-0000000FF1CE} at first glance it isn't obvious what software product this is (although Microsoft's use of hex digits to spell out "office" is clever).

我过去已经使用过很多次,并且此方法确实可以卸载软件。 但是,我确实有一些问题,首先是GUID方法不是非常用户友好。 查看以下用于Office 2007 Professional的GUID {90120000-0011-0000-0000-0 000000FF1C 乍看之下,这到底是什么软件产品尚不清楚(尽管Microsoft使用十六进制数字拼写“办公室”是很聪明的)。

Utilizing the GUID found in the registry you would end up with an uninstall string like:

利用在注册表中找到的GUID,您将得到一个卸载字符串,例如:

MsiExec.exe /x {90120000-0011-0000-0000-0000000FF1CE} /qn

If you are in a situation with multiple administrators, this could be difficult for those who did not write the script to know what program it is supposed to remove.

如果您有多个管理员,对于那些没有编写脚本的人来说,要知道应该删除哪个程序可能会很困难。

Another limitation that I have run into using the GUID uninstall method is that minor version changes of the same software can have different GUIDs. A software product version 7.1.2 may have a different GUID from that of version 7.1.5.  This would require multiple MSIEXEC commands to address these software installations with different GUIDs.

我在使用GUID卸载方法时遇到的另一个限制是,同一软件的次要版本更改可能具有不同的GUID。 软件产品版本7.1.2可能具有与版本7.1.5不同的GUID。 这将需要多个MSIEXEC命令来使用不同的GUID解决这些软件安装问题。

WMIC方法
(The WMIC Method
)

最近,我一直在使用另一种技术来卸载软件。 我的新首选方法利用WMIC命令。 WMIC可以在许多方面对管理员有所帮助,但是我将不对本文的所有功能进行详尽的解释。 如果您不熟悉并且想了解更多信息,这篇TechNet文章将为您提供非常好的入门知识: WMIC - Take Command-line Control over WMIWMIC-通过WMI进行命令行控制 http://technet.microsoft.com/en-us/library/bb742610.aspx http://technet.microsoft.com/zh-CN/library/bb742610.aspx

One of the key benefits I have found using WMIC is that the commands are much simpler than the MSIEXEC method mentioned above. Using WMIC there is no more searching the registry, finding GUIDs, and no more confusing MSIEXEC commands. The commands issues are much more human friendly as you will see in the examples below.

我发现使用WMIC的主要好处之一是命令比上面提到的MSIEXEC方法简单得多。 使用WMIC,不再需要搜索注册表,查找GUID,也不会使MSIEXEC命令混乱。 如您将在以下示例中看到的,命令问题更加人性化。

例: (Example: )

Using WMIC to uninstall a software product by exact name

使用WMIC按确切名称卸载软件产品

WMIC product get name

Once you have found the name of the software you would like to remove, copy the name exactly as it appears in the output.  And modify the following command's ProductName section.

找到要删除的软件的名称后,请完全按照输出中显示的名称进行复制。 并修改以下命令的ProductName部分。

    WMIC product where name="ProductName" call uninstall

WMIC产品,其中name =“

For instance...

例如...

Hitting enter will begin the uninstallation process for the desired software.  The uninstallation will automatically run silently with no user interaction.

按Enter键将开始所需软件的卸载过程。 卸载将自动静默运行,无需用户干预。

例: (Example:)

Using WMIC to uninstall a software product by wildcard name

使用WMIC按通配符名称卸载软件产品

It is possible to use the same WMIC command with wildcards to uninstall multiple versions of a software.  For example Adobe Reader versions 7, 8, and 9 could be installed on machines in your organization.  To remove all of these using the same command, you would use the LIKE operator and the % character wildcard, as in this command:

可以对通配符使用相同的WMIC命令来卸载软件的多个版本。 例如,可以在组织中的计算机上安装Adobe Reader版本7、8和9。 要使用同一命令删除所有这些命令,请使用LIKE运算符和字符通配符,如以下命令所示:

例: (Example:)

Using WMIC to uninstall software on a remote machine by exact name

使用WMIC按确切名称卸载远程计算机上的软件

computername with the desired target computer.

It is also possible to target multiple computers.  Simply separate the computername strings with commas.

也可以将多台计算机作为目标。 只需用逗号分隔

例: (Example:)

Using WMIC to uninstall software on a remote machine by wildcard search

使用WMIC通过通配符搜索在远程计算机上卸载软件

小费: (Tip:)

Using WMIC in a batch file (startup script)

在批处理文件中使用WMIC(启动脚本)

If using WMIC in a batch file you will want to use the local commands since each machine will be running the batch file individually.  To have WMIC successfully uninstall a product, you can set the script as a computer startup script. Since startup scripts run under the SYSTEM context, it will have the administrative rights that your users don’t have.

如果在批处理文件中使用WMIC,您将要使用本地命令,因为每台计算机将单独运行该批处理文件。 要使WMIC成功卸载产品,可以将脚本设置为计算机启动脚本。 由于启动脚本在SYSTEM上下文中运行,因此它将具有您的用户所没有的管理权限。

There are a million different ways to use the WMIC command line and this is only one application. If you found your way here I hope this was of some assistance to you. If you have any questions please feel free to post them and I will do my best to answer them.        

使用WMIC命令行有百万种不同的方式,但这只是一个应用程序。 如果您在这里找到自己的出路,希望对您有所帮助。 如果您有任何疑问,请随时发布,我将尽力回答。

翻译自: https://www.experts-exchange.com/articles/4105/Software-Uninstallation-using-WMIC-command-line.html

wmic卸载程序命令

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值