Uninstall the previous installed msi created with cx_freeze bdist_msi

I often use cx_freeze to pack my python source with all the dependencies and subsequently create the msi installation package via distutils bdist_msi extension

The only problems arise when I try to reinstall the newly created MSI window installer without uninstalling the previous version. The uninstaller records all previously uninstalled software versions, and it records registry information and uninstall information.

Is it possible to detect a previously installed version of my software and uninstall it automatically without installing a new version?

I know NSIS , and how to create installers with its python bindings, the aforementioned problem that I talked about can be easily solved with This. Unfortunately, at the moment I am not looking at anything other than what Python provides, i.e. distutils.

+4
source share
2 answers

Cx_Freeze bdist_msi has an upgrade-code option, which the docs describe as:

Define the update code for the package being created. it is used to force remove any packages created using the same update code before installing this

To specify it, I think you need to pass it to the setup() call something like this:

 options = {"bdist_msi": {"upgrade-code":"..."}} 

(I always forget if it should be - or _ in the option names to use them like this, so if this is wrong try as upgrade_code )

Microsoft will say that the update code must be a GUID (randomly generated code).

+7
source

Thomas K's answer is close, but at least, in my case, not accurate. After some trial and error, I found that the GUID should be enclosed in braces:

 bdist_msi_options = { "upgrade_code": "{96a85bac-52af-4019-9e94-3afcc9e1ad0c}" } 

and these parameters must be passed along with the "build_exe" parameters (some online examples use different names for these arguments, but I found that only bdist_msi works):

 setup( # name, version, description, etc... options={"build_exe": build_exe_options, # defined elsewhere "bdist_msi": bdist_msi_options}, executables=[Executable("run.py", base="win32GUI", shortcutName="My Program name", shortcutDir='ProgramMenuFolder')]) 

With this code, in my case, the previous installers were correctly removed and removed from the list of add / remove programs.

+5
source

All Articles