I have made an installer for MyProgram but the uninstall shortcut that it creates leaves behind empt

Posted by Coder7862396 on Stack Overflow See other posts from Stack Overflow or by Coder7862396
Published on 2010-05-30T22:08:41Z Indexed on 2010/05/30 22:12 UTC
Read the original article Hit count: 710

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.

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about deployment