简体   繁体   English

如何使用 python 卸载程序?

[英]How can I use python to uninstall programs?

A family member uses a Tobii eye-tracking device to control their laptop.一位家庭成员使用 Tobii 眼动追踪设备来控制他们的笔记本电脑。 Unfortunately, the Tobii software is poor and requires a fresh installation after every Windows update.不幸的是,Tobii 软件很差,每次 Windows 更新后都需要重新安装。 I am trying to write a script that would uninstall all 9 Tobii programs and then reinstall them.我正在尝试编写一个脚本来卸载所有 9 个 Tobii 程序,然后重新安装它们。

My code returned Method execution successful after each subprocess.call .我的代码在每个subprocess.call之后返回Method execution successful The Tobii eye-tracking stopped working but I can still see all 9 programs in the control panel. Tobii 眼动追踪停止工作,但我仍然可以在控制面板中看到所有 9 个程序。 I had to manual uninstall each program from the control panel.我不得不从控制面板手动卸载每个程序。 Why does my code not work?为什么我的代码不起作用? Is there any other way I can uninstall the programs via a python script?有没有其他方法可以通过 python 脚本卸载程序?

import os
import subprocess
import time
import wmi

tobii_programs = ["Tobii IS4 Eye Tracker Driver", "Tobii IS3 Eye Tracker Driver", "Tobii Eye Tracker Browser",
                 "Tobii Dynavox PCEye Update Notifier", "Tobii Dynavox PCEye Configuration Guide",
                 "Tobii Dynavox Gaze Selection Language Packs", "Tobii Dynavox Gaze Interation Software",
                 "Tobii Dynavox Gaze HID", "Tobii Service"]

def main():
    tobii_uninstall()

def tobii_uninstall():
    for program in tobii_programs:
        print(f"Uninstalling {program}...")
        subprocess.call(f"wmic product where name='{program}' call uninstall /nointeractive", shell=True)
    print("All Tobii software have been uninstalled.")

#def tobii_install():

if __name__ == "__main__":
    main()

A family member uses a Tobii eye-tracking device to control their laptop.一位家庭成员使用 Tobii 眼动追踪设备来控制他们的笔记本电脑。 Unfortunately, the Tobii software is poor and requires a fresh installation after every Windows update.不幸的是,Tobii 软件很差,每次 Windows 更新后都需要重新安装。 I am trying to write a script that would uninstall all 9 Tobii programs and then reinstall them.我正在尝试编写一个脚本来卸载所有 9 个 Tobii 程序,然后重新安装它们。

My code returned Method execution successful after each subprocess.call .我的代码在每个subprocess.call之后返回Method execution successful The Tobii eye-tracking stopped working but I can still see all 9 programs in the control panel. Tobii 眼动追踪停止工作,但我仍然可以在控制面板中看到所有 9 个程序。 I had to manual uninstall each program from the control panel.我不得不从控制面板手动卸载每个程序。 Why does my code not work?为什么我的代码不起作用? Is there any other way I can uninstall the programs via a python script?有没有其他方法可以通过 python 脚本卸载程序?

import os
import subprocess
import time
import wmi

tobii_programs = ["Tobii IS4 Eye Tracker Driver", "Tobii IS3 Eye Tracker Driver", "Tobii Eye Tracker Browser",
                 "Tobii Dynavox PCEye Update Notifier", "Tobii Dynavox PCEye Configuration Guide",
                 "Tobii Dynavox Gaze Selection Language Packs", "Tobii Dynavox Gaze Interation Software",
                 "Tobii Dynavox Gaze HID", "Tobii Service"]

def main():
    tobii_uninstall()

def tobii_uninstall():
    for program in tobii_programs:
        print(f"Uninstalling {program}...")
        subprocess.call(f"wmic product where name='{program}' call uninstall /nointeractive", shell=True)
    print("All Tobii software have been uninstalled.")

#def tobii_install():

if __name__ == "__main__":
    main()

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

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