简体   繁体   中英

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. 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.
  • Winapps : Except the list applications command none of the other functions return any values. 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:

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:

$MyApp.Uninstall()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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