简体   繁体   English

如何使用 python 卸载应用程序?

[英]How to uninstall an application using python?

I'm using Spyder as an IDE on Windows 10 and I've been searching for python programs that will uninstall particular applications upon execution.我在 Windows 10 上使用 Spyder 作为 IDE 并且我一直在搜索 python 程序,这些程序将在执行时卸载特定的应用程序。 So far, I have found a couple of sources:到目前为止,我已经找到了几个来源:

  • Stackoverflow : The wmic command does not seem to be recognized by Spyder and returns an invalid syntax error. Stackoverflow :Spyder 似乎无法识别 wmic 命令并返回无效的语法错误。
  • Winapps : Except the list applications command none of the other functions return any values. Winapps :除了 list applications 命令之外,其他函数都没有返回任何值。 I tried the following code but to no avail:我尝试了以下代码但无济于事:
for app in winapps.search_installed('[app_name]'):
        print(app)

winapps.uninstall('[app_name]', args=['/S'])

Are there any other modules and/or methods I can use to uninstall applications on my system?是否有任何其他模块和/或方法可以用来卸载系统上的应用程序?

If you can call PowerShell commands with Administratos rights, maybe could you use this method:如果您可以使用管理员权限调用 PowerShell 命令,也许您可以使用此方法:

List the installed applications:列出已安装的应用程序:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name

Create a variable with informations about the app that you want to uninstall:创建一个包含您要卸载的应用程序信息的变量:

$MyApp = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Java Auto Updater"}

And after, just call the Uinstall Method:之后,只需调用 Uinstall 方法:

$MyApp.Uninstall()

在此处输入图像描述

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

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