Uninstalling an app prior to upgrading

I have an app 7-zip and I’ve found its exe in the registry and applied to relevance in a software distribution for the app. I need to run the uninstall program located in D:\Program Files\7-Zip prior to installing the new version in the same folder location, which I’ve selected in the new software distribution task created. What is the action that I place in front of the prefetch .exe = to run the uninstall before launching the install command. I’ve found the registry key for the uninstall “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip” and the string name is UninstallString.

Here you go -

// Remove the 64-bit EXE version
if {exists key whose (value "DisplayName" of it as string as lowercase contains "7-zip" AND value "UninstallString" of it as string as lowercase contains "uninstall") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registry)}
waithidden {value "UninstallString" of key whose (value "DisplayName" of it as string as lowercase contains "7-zip" AND value "UninstallString" of it as string as lowercase contains "uninstall") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registry)} /S
endif

// Remove the 32-bit EXE version
if {exists key whose (value "DisplayName" of it as string as lowercase contains "7-zip" AND value "UninstallString" of it as string as lowercase contains "uninstall") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registry)}
waithidden {value "UninstallString" of key whose (value "DisplayName" of it as string as lowercase contains "7-zip" AND value "UninstallString" of it as string as lowercase contains "uninstall") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registry)} /S
endif
1 Like