1

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?

mgr
  • 561
  • 1
  • 7
  • 22
  • 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 May 22 '15 at 11:01
  • 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 May 22 '15 at 11:14
  • See [section 3 in this post](http://stackoverflow.com/questions/450027/uninstalling-an-msi-file-from-the-command-line-without-using-msiexec/1055933#1055933) for information on the proper syntax to uninstall your MSI file. – Stein Åsmul May 22 '15 at 12:59

2 Answers2

1

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/

PhilDW
  • 19,260
  • 1
  • 14
  • 23
  • This is working for me. But the thing how can I delete my installer from the temp location as part of uninstall process. Is there any way to do it?? If I ad delete to this batch file it is not working as expected to unisntall.. SET tempLoc="%USERPROFILE%\AppData\Local\Temp" copy "%CD%\Config\Api.msi" %tempLoc% cd %tempLoc% cmd.exe /c start "" "Api.msi" ##del Api.msi exit; – mgr May 25 '15 at 15:31
  • Honestly, I wouldn't bother deleting it. If you look at the temp folder there are typically lots of files left there; there are cleanup tools if the user cares. – PhilDW May 25 '15 at 19:30
0

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.

Kyanar
  • 11
  • 1
  • I am copying the MSI into the installation location to have Repair option. When the user clicks on the uninstall shortcut from the program-menu options, it gives the user Repair and Remove options. For this reason we are copying the MSI to instillation location. As you said, "as the Windows Installer will make a copy itself and place it in %windir%\Installer", does this provide the Repair option? – mgr May 26 '15 at 10:51
  • Ok. got it. below way, I can do it. will test it. – mgr May 26 '15 at 11:41