I have made an installer for MyProgram but the uninstall shortcut that it creates leaves behind empt
- by Coder7862396
I have created an installer for MyProgram using the Visual Studio Installer (Visual Studio Setup Project). It is called "MyProgram Setup.msi". It installs the program fine and if it is uninstalled using the Add/Remove Programs control panel then everything gets removed as it should.
The problem is that I want to add a shortcut to the "User's Programs Menu" under the program shortcut called "Uninstall MyProgram". I have tried doing this in 3 different ways and in all 3 ways if MyProgram is uninstalled using that shortcut, the uninstall will leave behind 2 empty folders ("...Program Files\MyCompany\" and "...Program Files\MyCompany\MyProgram\").
Here are the 3 ways that I have tried to make an uninstaller shortcut:
1) A shortcut to a batch or script file
Uninstall MyProgram.bat:
@ECHO OFF
msiexec /uninstall {MyGUID}
Uninstall MyProgram.vbs:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing
2) Editing the MSI file using Orca.exe
I found out how to do this using this guide: http://www.codeproject.com/KB/install/MSIShortcuts.aspx
I added the Shortcut Entry to the Shortcut table. Uninstalling worked but it still left behind the 2 empty folders when using this shortcut.
3) From code within MyProgram.exe
I modified MyProgram.exe to take a "/uninstall" command line parameter to run "msiexec.exe /uninstall {MyGUID}" and exit itself. Similar to this solution: http://www.codeproject.com/KB/install/DeployUninstall.aspx
None of these attempts created a shortcut which can uninstall the program as well as the program's base folders. I don't want to switch to some other installer product such as Inno Setup, NSIS, or WiX.