Open Seersha16 opened 5 months ago
I tried installing just for the current user with the SYSTEM account, and every installation attempt failed, so I can't reproduce that setup, if I'm understanding you correctly. Which user account was used to install which version(s) of Python? How was the installer originally executed? Also, which user account are you using to try to uninstall Python?
@eryksun
I am using SYSTEM account for uninstalling all the older versions from a windows server. I do not have visibility to how the installer was executed but from the path seen in registry it looks like it was installed for the user scope from a user account. These versions fail to uninstall with SYSTEM account. The versions installed for all users are getting uninstalled with SYSTEM account.
Oh, you're using the SYSTEM account to try to uninstall a per-user installation of Python that was installed by another user. To uninstall cleanly, the installer needs to be run using that user account. Do you have their password, or can you assign the account a new password?
@eryksun No, I don't have their password and cannot assign a new password either. This is part of an automation and it is expected to uninstall the versions on different windows server irrespective of how the installation was performed. Is there any way to uninstall per user installations from SYSTEM account.
Is there any way to uninstall per user installations from SYSTEM account.
Not cleanly, as far as I know, and I wouldn't recommend attempting it.
There should be subkeys for the installation in the user's registry key as well as the local-machine hive at "Software\Microsoft\Windows\CurrentVersion\Uninstall". The keys have GUID names, so it's tedious to search through them manually to find the ones related to the Python installation. There are also related directories in the user's "AppData\Local\Package Cache", with directory names that should correspond to the GUID key names in the "Uninstall" subkeys. The installation directory for Python version X.Y[-32] should be the default value of the user's registry key "Software\Python\PythonCore\X.Y[-32]\InstallPath".
You could load the user's registry settings from their profile directory (i.e. load their "ntuser.dat" hive as a subkey of HKEY_USERS
). Remove the installation's subkey from their "Uninstall" key; remove all of the related subkeys for the installation from the machine "Uninstall" key; delete the associated directories from the user's package cache; delete the installation directory; remove file associations stored in the user's software classes in the registry (you'd have to load the hive file "AppData\Local\Microsoft\Windows\UsrClass.dat"); and delete the installation's start-menu directory in "AppData\Roaming\Microsoft\Windows\Start Menu\Programs".
I cannot recommend manually removing any of this. There's a lot of potential to mess things up.
Your best bet is to use the SYSTEM account to set up a script or scheduled task for each user that will scan and do the install then.
I still wouldn't recommend it, unless you want your users to hate you (and find way to work around you), but it is possible.
in testing python from remote servers (various) ran into the same issue but spun on this until had tried everything. if not uninstalled with the same user as installed with the python fails to remove an 'all users install' regardless of flags and reports success. all user installs when targeted believe should be removeable.. perhaps flag for allusersremove? seems like the install is leaving stuff on the installing users regardless of flags..
python also appears to not return exit codes to the os during this. they are in the logs
When trying to uninstall all python versions installed on windows server, only the versions installed initially for all users are getting uninstalled from SYSTEM account. Tried installing the user scope versions for all users and then uninstalling but the version still fails to uninstall.
Command tried for uninstallation: Start-Process -FilePath $installerPath -ArgumentList "/uninstall /quiet" -NoNewWindow -Wait -PassThru
This command does not show any error but the version remains installed on the machine.