Friday, November 24, 2006

Gotcha - How to add uninstall option in the “User’s Program Menu” for web setup project?

How to add uninstall option in the “User’s Program Menu” for web setup project?

The user doen’st have to go to control panel/add remove programs/ and then choose to uninstall the app, but just go to Start button, navigate to the app and choose uninstall!

Solution -
1. Create simple project UninstallApp.

2. Add in Main(){string[] arguments = Environment.GetCommandLineArgs();foreach(string argument in arguments){string[] parameters = argument.Split('=');if (parameters[0].ToLower() == "/u"){string productCode = parameters[1];string path = Environment.GetFolderPath(Environment.SpecialFolder.System);Process proc = new Process();proc.StartInfo.FileName = string.Concat(path,"\\msiexec.exe");proc.StartInfo.Arguments = string.Concat(" /i ", productCode);proc.Start();}}

3. Create new setup project

4. Add UninstallApp.exe to "Application Folder" in 'File System' part

5. In "User's Program menu" create shortcut to UninstallApp.exe and in properties of this shortcut in parameter 'arguments' insert value "/u=[ProductCode]".

6.Rebuild deployment project.

Thanks to Francisco Jileta and Michael Nielsen for pointing to us on this: http://gaaton.blogspot.com/2006/07/add-uninstall-and-him-shortcut-to-net.html

Hope it helps!

No comments: