I am trying to uninstall an application named BlueStacks App Player on Windows using the Vasily Ryabov example of 7z uninstall.
I'm getting the error:
C:\Users\ADMIN\PycharmProjects\untitled1\venv\Scripts\python.exe
C:/Users/ADMIN/PycharmProjects/untitled1/uninstall_software.py Traceback (most recent call last): File "C:/Users/ADMIN/PycharmProjects/untitled1/uninstall_software.py", line 5, in explorer = pywinauto.Application().connect(path='explorer.exe') File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pywinauto\application.py", line 1005, in connect self.__warn_incorrect_bitness() File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pywinauto\application.py", line 1083, in __warn_incorrect_bitness if self.backend.name == 'win32' and self.is64bit() != is_x64_Python(): File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pywinauto\application.py", line 1098, in is64bit return handleprops.is64bitprocess(self.process) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pywinauto\handleprops.py", line 183, in is64bitprocess phndl = win32api.OpenProcess(win32con.MAXIMUM_ALLOWED, 0, process_id) pywintypes.error: (87, 'OpenProcess', 'The parameter is incorrect.')
Process finished with exit code 1
The code is :
from __future__ import print_function
import pywinauto
pywinauto.Application().start(r'explorer.exe')
explorer = pywinauto.Application().connect(path='explorer.exe')
# Go to "Control Panel -> Programs and Features"
NewWindow = explorer.window_(top_level_only=True, active_only=True, class_name='CabinetWClass')
try:
    NewWindow.AddressBandRoot.ClickInput()
    NewWindow.TypeKeys(r'Control Panel\Programs\Programs and Features{ENTER}', with_spaces=True, set_foreground=False)
    ProgramsAndFeatures = explorer.window_(top_level_only=True, active_only=True, title='Programs and Features', class_name='CabinetWClass')
    # wait while list of programs is loading
    explorer.WaitCPUUsageLower(threshold=5)
    item_7z = ProgramsAndFeatures.FolderView.GetItem('BlueStacks App Player')
    item_7z.EnsureVisible()
    item_7z.ClickInput(button='right', where='icon')
    explorer.PopupMenu.MenuItem('Uninstall').Click()
    Confirmation = explorer.window_(title='Programs and Features', class_name='#32770', active_only=True)
    if Confirmation.Exists():
        Confirmation.Yes.ClickInput()
        Confirmation.WaitNot('visible')
    WindowsInstaller = explorer.window_(title='Windows Installer', class_name='#32770', active_only=True)
    if WindowsInstaller.Exists():
        WindowsInstaller.WaitNot('visible', timeout=20)
    SevenZipInstaller = explorer.window_(title='BlueStacks App Player', class_name='#32770', active_only=True)
    if SevenZipInstaller.Exists():
        SevenZipInstaller.WaitNot('visible', timeout=20)
    if 'BlueStacks App Player' not in ProgramsAndFeatures.FolderView.Texts():
        print('OK')
finally:
    NewWindow.Close()
 
    