Uninstall a msi from Python
Following my last post regarding how to list all installed applications using python here is the code that one will require to remove an installed msi from a Windows machine using python.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | class MsiException(Exception): """Raised when there are issues with the msi actions.""" def uninstall_product(uid): """Will remove the old beta from the users machine.""" # we use the msi lib to be able to uninstall apps property_name = u'LocalPackage' uninstall_path = get_property_for_product(uid, property_name) if uninstall_path is not None: # lets remove the package. command_line = u'REMOVE=ALL' result = windll.msi.MsiInstallProductW(uninstall_path, command_line) if result != ERROR_SUCCESS: raise MsiException('Could not remove product %s' % uid) |
The missing functions can be found in the last post about the topic.




