Question

I am attempting to implement a quiet uninstall of my application. This works great if the application is actually installed, but when it is not the user receives an error message and must click OK to continue.

My command:

MSIEXEC.EXE /qb /L* "%LOGDIR%\myuninstaller.log" /x{GUID}

The problem is that I need to clean up all old versions of the app in a script I deploy in AD. I don't know what version is installed on what computer, and making the script determine so first is difficult.

How can I make MSIEXEC NOT complain about uninstalling GUID's that don't exist?

Was it helpful?

Solution

If all your apps have proper GUID keys in "KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" you could also do something like this:

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID} >NUL 2>NUL || MSIEXEC.EXE /qb /L* "%LOGDIR%\myuninstaller.log" /x{GUID}

This would only start msiexec.exe if the key is present (and would be a bit more efficient than firing msiexec.exe on nonexistent GUIDs with /qn).

OTHER TIPS

Found the answer on http://technet.microsoft.com/en-us/library/cc759262(WS.10).aspx#BKMK_SetUI

It seems I need to use /qn instead of /qb.

For my case it works with: (notice the && operator)

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID} >NUL 2>NUL && MSIEXEC.EXE /qf /L* "%LOGDIR%\myuninstaller.log" /x{GUID}

according to this link http://www.robvanderwoude.com/condexec.php, the subsequent command (msiexec.exe) will only be executed if first command executed successfuly (without error result). You can try to test each command separately

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{GUID} >C:\registrycheck.log

Even though you have an accepted answer, please do check out this post from serverfault.com: Is it possible to disable msiexec help GUI?. There are many ways to uninstall an MSI via automation so you don't have to deal with msiexec.exe at all.

Perhaps this Uninstalling an MSI file from the command line without using msiexec is also useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top