Click here to Skip to main content
12,698,137 members (22,437 online)
Click here to Skip to main content
Add your own
alternative version


1 download
76 bookmarked

Add an uninstall start menu item to your .NET deployment project

, 21 Aug 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
The simple way to add an uninstall menu item to your .NET deployment project


It's super easy to add this to your deployment project.

  1. Select your deployment project and go to the file system editor, user programs menu.
  2. Add an additional shortcut to your primary output project and name it Uninstall Application.
  3. Set the Arguments property to /u=[ProductCode].
  4. Add the following code to your project's Main() sub or startup form's New() sub just before the call to InitializeComponent().
    Dim arguments As String() = Environment.GetCommandLineArgs()
    Dim argument As String
    For Each argument In arguments
        If argument.Split("=")(0).ToLower = "/u" Then
            Dim guid As String = argument.Split("=")(1)
            Dim path As String = _
            Dim si As New ProcessStartInfo(path & _
                      "\msiexec.exe", "/i " & guid)
        End If

That's is! The Deployment project will replace [ProductCode] in the Arguments property with the actual installer project's ProductCode GUID value. Your program will see the /u={Actual ProductCode} argument and pass it to msiexec.exe before exiting.

The installer is run in repair/remove mode for your application. The user is allowed to select repair or remove, and continue. If you want the product to remove only, replace the "/i " with "/x ".


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Systems Engineer Mark J Means Consulting
United States United States
I have been a software consultant since 1985 working on everything from the Commodore VIC-20 & RadioShack CoCo games to 8051 Embedded USB Microcontrollers to Windows Vista database applications. I have written over a half million lines of code since 2004. Please see my DataConnectionDialog control at

You may also be interested in...


Comments and Discussions

QuestionThanks Pin
Kashif Alvi25-Jun-13 12:02
memberKashif Alvi25-Jun-13 12:02 
QuestionWorked but getting an error in some machines Pin
Vaidehi P16-May-11 21:21
memberVaidehi P16-May-11 21:21 
AnswerRe: Worked but getting an error in some machines Pin
mjmeans17-May-11 12:00
membermjmeans17-May-11 12:00 
GeneralVerifying The Link... [modified] Pin
jp2code15-Sep-10 13:04
memberjp2code15-Sep-10 13:04 
GeneralCondensed C# Code Pin
Geo24227-May-10 14:01
memberGeo24227-May-10 14:01 
GeneralRe: Condensed C# Code Pin
satheesh.palanisamy28-Sep-12 4:10
membersatheesh.palanisamy28-Sep-12 4:10 
GeneralCode in C# Pin
Nitin Sawant3-Dec-09 16:53
memberNitin Sawant3-Dec-09 16:53 
QuestionWhere should I put these codes? Pin
qiux4-Sep-09 1:51
memberqiux4-Sep-09 1:51 
AnswerRe: Where should I put these codes? Pin
mjmeans6-Sep-09 0:01
membermjmeans6-Sep-09 0:01 
QuestionHow to Show Product Name while confirming the Unistallation? Pin
oops.uvj19-Aug-09 21:45
memberoops.uvj19-Aug-09 21:45 
AnswerRe: How to Show Product Name while confirming the Unistallation? Pin
mjmeans20-Aug-09 8:22
membermjmeans20-Aug-09 8:22 
AnswerRe: How to Show Product Name while confirming the Unistallation? Pin
stratokazik17-Aug-10 20:45
memberstratokazik17-Aug-10 20:45 
GeneralThank you Pin
Sintre8-Jun-09 12:14
memberSintre8-Jun-09 12:14 
GeneralOne Problem [modified] Pin
thirstyDev26-Nov-08 19:43
memberthirstyDev26-Nov-08 19:43 
GeneralRe: One Problem Pin
mjmeans27-Nov-08 8:37
membermjmeans27-Nov-08 8:37 
GeneralRe: One Problem Pin
thirstyDev27-Nov-08 18:46
memberthirstyDev27-Nov-08 18:46 
GeneralEven easier solution Pin
Vyacheslav Trubarov3-Nov-07 15:28
memberVyacheslav Trubarov3-Nov-07 15:28 
NewsRe: Even easier solution Pin
Bilal Haider Asi13-Mar-08 9:46
memberBilal Haider Asi13-Mar-08 9:46 
GeneralNo Code Solution VS2005 Pin 6:52 6:52 
GeneralRe: No Code Solution VS2005 Pin
mjmeans9-Aug-07 8:26
membermjmeans9-Aug-07 8:26 
GeneralRe: No Code Solution VS2005 Pin
cedear19-May-08 6:50
membercedear19-May-08 6:50 
GeneralRe: No Code Solution VS2005 Pin
nnans29-Oct-08 1:07
membernnans29-Oct-08 1:07 
GeneralRe: No Code Solution VS2005 Pin
mjmeans29-Oct-08 7:16
membermjmeans29-Oct-08 7:16 
GeneralRe: No Code Solution VS2005 Pin
nnans29-Oct-08 18:07
membernnans29-Oct-08 18:07 
GeneralRe: No Code Solution VS2005 Pin
mjmeans30-Oct-08 3:08
membermjmeans30-Oct-08 3:08 
Generala better alternative Pin
Jujiswa25-Feb-07 13:51
memberJujiswa25-Feb-07 13:51 
GeneralRe: a better alternative Pin
logan133728-Jul-07 8:46
memberlogan133728-Jul-07 8:46 
GeneralRe: a better alternative Pin
logan133731-Jul-07 5:26
memberlogan133731-Jul-07 5:26 
QuestionSingle Uninstaller Pin
yachitha2-Nov-06 4:24
memberyachitha2-Nov-06 4:24 
QuestionRemove app directory Pin
enricc7-Aug-06 22:48
memberenricc7-Aug-06 22:48 
AnswerRe: Remove app directory Pin
enricc7-Aug-06 23:41
memberenricc7-Aug-06 23:41 
GeneralRe: Remove app directory Pin
evgeniyn1-Jun-07 21:07
memberevgeniyn1-Jun-07 21:07 
GeneralDot Net Deployment Pin
chudapji12-Jan-06 19:24
memberchudapji12-Jan-06 19:24 
GeneralRe: Dot Net Deployment Pin
Subomania28-Jun-06 1:49
memberSubomania28-Jun-06 1:49 
GeneralAnother argument to Msiexec.exe Pin
dapoussin2-Jan-06 3:55
memberdapoussin2-Jan-06 3:55 
Generaldon't work in web Pin
Victor Velepucha27-Aug-05 12:11
memberVictor Velepucha27-Aug-05 12:11 
GeneralNice but... Pin
dan neely23-Aug-05 6:47
memberdan neely23-Aug-05 6:47 
GeneralRe: Nice but... Pin
mjmeans23-Aug-05 13:24
membermjmeans23-Aug-05 13:24 
GeneralRe: Nice but... Pin
DanNeely23-Aug-05 16:41
sussDanNeely23-Aug-05 16:41 
GeneralRe: Nice but... Pin
mcarbenay23-Aug-05 23:40
membermcarbenay23-Aug-05 23:40 
GeneralRe: Nice but... Pin
mjmeans24-Aug-05 21:55
membermjmeans24-Aug-05 21:55 
GeneralRe: Nice but... Pin
mcarbenay24-Aug-05 23:24
membermcarbenay24-Aug-05 23:24 
GeneralRe: Nice but... Pin
mjmeans25-Aug-05 9:45
membermjmeans25-Aug-05 9:45 
AnswerMSDN link here - How do I create an uninstall link on my shortcut? Pin
Buzzle744-Nov-08 15:35
memberBuzzle744-Nov-08 15:35 
Generalworks but... Pin
JabraJabra21-Aug-05 23:10
memberJabraJabra21-Aug-05 23:10 
GeneralRe: works but... Pin
mjmeans22-Aug-05 14:04
membermjmeans22-Aug-05 14:04 
GeneralRe: works but... Pin
mjmeans22-Aug-05 14:22
membermjmeans22-Aug-05 14:22 
GeneralRe: works but... Pin
JabraJabra22-Aug-05 23:35
memberJabraJabra22-Aug-05 23:35 
GeneralRe: works but... Pin
John Kang23-Aug-05 5:41
memberJohn Kang23-Aug-05 5:41 
GeneralRe: works but... Pin
JabraJabra23-Aug-05 22:43
memberJabraJabra23-Aug-05 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 21 Aug 2005
Article Copyright 2005 by mjmeans
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid