DCSIMG
Add an uninstall shortcut to setup project - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

Add an uninstall shortcut to setup project

Add an uninstall shortcut to setup project

1. Create simple project UninstallApp.
2.

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();
        }
    }
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

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.

Comments

Jos said:

With the code above, will the UninstallApp program also remove itself?

Usually, programs can not remove themselves while running.

Jos

# July 14, 2008 3:32 PM

Jorge D'Angelo said:

Where find [ProductCode]

# July 21, 2009 5:30 PM

Paquito said:

It Works!

# September 16, 2009 5:53 PM

Jaime peixe said:

Thanks.It's a great POST!

# January 13, 2010 1:56 AM

Shay N said:

Thanks!

# February 13, 2010 12:23 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: