windows 如何使用 python 或(和)ruby 卸载任何应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6978391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to uninstall any application using python or (and) ruby
提问by Alexander.Iljushkin
I didn't find any helpful topics over the webs by this question. These all about how to uninstall python or uninstall ruby but there are no information about the #{TOPIC}.
我没有通过这个问题在网上找到任何有用的话题。这些都是关于如何卸载python或卸载ruby的,但没有关于#{TOPIC}的信息。
The main problem is that I used other interesting answersto try to uninstall an application using PowerShell script but all that didn't help me because that script with several variants of -Query "query" never finds my application even by unrigorous mask like '%APPL_NAME%' or by version number.
主要问题是我使用了其他有趣的答案来尝试使用 PowerShell 脚本卸载应用程序,但所有这些都没有帮助我,因为带有 -Query "query" 的几种变体的脚本从未找到我的应用程序,即使是像 '% 这样不严谨的掩码APPL_NAME%' 或按版本号。
Seems like table Win32_Product filled uncorrectly or any function works bad now. Moreover, for me, it's not so cool to use PowerShell if I have such flexible languages.
似乎表 Win32_Product 填充不正确或任何功能现在都无法正常工作。而且,对我来说,如果我有这么灵活的语言,使用 PowerShell 并不是那么酷。
So i'm interested in ways how to uninstall any program through the ruby or python.
所以我对如何通过 ruby 或 python 卸载任何程序感兴趣。
Thank you for any ideas :-)
谢谢你的任何想法:-)
Edit: Let's I ask the question to another way. How to uninstall ordinary program which was installed thruogh the MSI installer
编辑:让我以另一种方式提出问题。如何卸载通过 MSI 安装程序安装的普通程序
Edit: Why so strongly ? I'm not a perfect IT man moreover I'm from russia and don't know english well. I do not deserve minus ratings. You can stay it on zero. Thank you.
编辑:为什么这么强烈?我不是一个完美的 IT 人,而且我来自俄罗斯并且不太懂英语。我不值得负分。您可以将其保持为零。谢谢你。
Edit: Thank's for all responses. I appreciate it.
编辑:感谢所有回复。我很感激。
采纳答案by ray_linn
You can invoke WMIC command in ruby or python. the process is as following:
您可以在 ruby 或 python 中调用 WMIC 命令。过程如下:
wmic product get name
wmic product get name
This command will list all the software with a formal name, for example, to the office product, the name could be 'Microsoft office 20003 Pro' or 'Microsoft office 2003 Home & Student', you can use ruby or python to filter out what is the extacly name and then execute
该命令将列出所有具有正式名称的软件,例如对于办公产品,名称可以是“Microsoft office 20003 Pro”或“Microsoft office 2003 Home & Student”,您可以使用ruby 或python 过滤掉什么是确切的名称然后执行
wmic product where name='Microsoft office 2003 Home & Student' call uninstall
wmic product where name='Microsoft office 2003 Home & Student' call uninstall
replace 'Microsoft office 2003 Home & Student' with the application you like.
用您喜欢的应用程序替换“Microsoft office 2003 Home & Student”。
if you prefer no to execute the wmic directly , and you can import python wmi or ruby wmi instead.
如果你不想直接执行 wmic ,你可以导入 python wmi 或 ruby wmi 代替。
回答by Bulwersator
"uninstall anyprogram" - evil/badly designed program may create files hidden in many places - and I see no way to create program that can find all of them. (For example: any includes all kinds of malware)
“卸载任何程序” - 邪恶/设计不当的程序可能会创建隐藏在许多地方的文件 - 我认为没有办法创建可以找到所有这些文件的程序。(例如:any 包括各种恶意软件)
回答by Matt
you can do plenty with msi based installation via the msiexec command. You could run\spwan this from your scripting language of choice.
您可以通过 msiexec 命令使用基于 msi 的安装做很多事情。您可以从您选择的脚本语言运行\spwan。
msiexec /?
You'll need the package information (mainly the GUID) - this can be found here:
您将需要包信息(主要是 GUID)——可以在这里找到:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer
The Product
subkey is probably the most interesting for you.
该Product
子项可能是你最感兴趣的。
HTH, Matt
HTH,马特