1
votes

MSI (created from WIX)- Uninstall application is not removing the root installation folder.

1) I have installed the MSI (example: selected installation root location: C:/MSI_test/ and installed with AppName. And final location is C:/MSI_test/AppName/) and part of the installation copied MSI into my installation location (for repair purpose from uninstall shortcut Key. When I click the uninstall shortcut it points to the MSI in my installed directory and opens a dialog with Repair or Remove option)

2) If the user tries to uninstall this application from the uninstall shortcut, it removes all the installed files and folders but not removing the root installation location (i.e. C:/MSI_test/AppName/).

Below is the code having in my uninstall.bat file (which is called during uninstall shortcut)

cmd.exe /c start "" "C:\MSI_test\AppName\Config\App.msi"
exit;

3) If I have MSI in different location (i.e. in C:/testing) and trying to uninstall the application, it removes everything (i.e. installed files and folders including root installation location)

4) Is this a problem to delete the root folder if we are trying to uninstall from the above step-2 to delete the root installation folder?

2
The folder should get removed if there are no locks on it (running services, files in use, etc...) and no remaining files towards the end of the uninstall process. You can also see such a problem if a command prompt window is open with the path in question as its current directory.Stein Åsmul
Yes you are right, if we do from command prompt, it is the same problem (due to lock) it will not delete. So in my case is it holding any locks? I have modified above post point-2 (added my uninstal.bat code)mgr
See section 3 in this post for information on the proper syntax to uninstall your MSI file.Stein Åsmul

2 Answers

1
votes

The problem you're having is likely to be that your uninstall is holding the folder open. I've solved this problem previously by creating an exe that does the uninstall and copying it to the Temp folder andf running the uninstall program from there, and people generally clean up the temp folder anyway.

This might be a better way of doing it too:

http://robmensching.com/blog/posts/2007/4/27/how-to-create-an-uninstall-shortcut-and-pass-all-the/

0
votes

What you're seeing is the result of a lock being placed on that folder or its contents, likely as a result of the batch file itself executing (which sets the working directory of the command interpreter running it to the folder it is in, and places a read lock on the folder).

That said, I'm unsure why you're making a copy of the MSI in the application folder anyway, as the Windows Installer will make a copy itself and place it in %windir%\Installer. When you kick off your uninstall from the shortcut, the installer reads the product code from the MSI you provided it and then goes back to the cached copy anyway.

Ideally, you should do away with the batch file and place a direct shortcut to msiexec.exe /i {product-code} - this will kick off the installation/maintenance UI for your product if it is installed. If you must have a batch file, you will need to place it outside your application's installation root.