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


29 bookmarked

An Uninstaller To Uninstall Any .NET Application

, 2 Aug 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Create an Uninstaller to Uninstall Any Installed .NET Application


I have named this utility as uninstaller because this utility can be used to uninstall any .NET application which is deployed using .NET deployment wizard [Windows Installer].


I was fedup by uninstalling .NET application from AddRemove programs. I wanted something like a standard uninstaller so you just need to double click and it will uninstall your application.

You can create your uninstaller using Orca, a utility to update your MSI, but that is not a simple task. It is very complicated and whenever you build your setup you have to do the same thing again and again.

So I am here to help out people who don't know how to create standard uninstaller for their .NET application.

Using the Code

To use this utility, first you have to create a setup project in .NET. After adding Primary output of your application in setup project, build the setup project.

Now create a batch file called uninstall.bat anywhere on your file system. In the batch file, write the statements given below:


This will set the commands to hide.

If at setup install path your application will create any directory at run time, then add the line given below in uninstall.bat file to remove the directory contents.

DEL DirectoryName /q

Add one command to clear your command prompt screen so that no one can come to know what your utility is doing behind the scenes.


Then to remove the directory itself, you will have to add one more line given below:

RMDIR DirectoryName

If your application is creating any file at runtime, you need to clear those files also at uninstallation. To achieve that, you can add the line given below:

DEL FielName<.txt|.xml>

This will remove the file specified.

Now here is the main command which will uninstall your application, so I hope you have understood the command specified above, if not then please understand those commands first.

Now the command given below will remove all the files which were created by the installer and remove the application from the system.

C:\WINDOWS\system32\MsiExec.exe /Uninstall {455EAB09-DEC0-4EBF-8B4D-130004A7537D} 
/qr /li <LogFileName.txt>

C:\WINDOWS\system32\MsiExec.exe = Path of the MsiExec.exe file present in System folder, make sure it exists on the target machine or change the path accordingly.

/Uninstall = This is a command to tell the MsiExec.exe that you are performing uninstallation.

{455EAB09-DEC0-4EBF-8B4D-130004A7537D} = This is the most important part of the utility, this is the product code of your application.
You can get this product code from your application setup project in properties window of
your setup project. [Select project node in Solution Explorer and click F4 and copy the Product code.]

If you change the version of your application in setup project, then the product code is changed so whenever you change the version just copy the new product code and replace it in uninstall.bat file.

/qr = This is the command to tell MsiExec.exe that you will be performing uninstallation in GUI mode, but with less GUI, it means it will not ask you to repair your application.

There are multiple combinations to achieve different modes of uninstallation, like:

qn = No UI.
qb = Basic UI 
qf = Full UI [default] (It will ask you to either repair or uninstall your application. )

quiet = Quiet mode, no user interaction
passive = Unattended mode - progress bar only

Now if you want to create a log for your application uninstallation, then add one more command
given below:

/li <Log File Name e.g. MyAppLog.txt>

This will create a log file with a name of MyAppLog.txt.

And now uninstallation is done.

Now you have to include this batch file in the setup project where your primary output is going and you can create a shortcut of this batch file and put in programs menu if you are creating shortcuts for your application.

So when setup is installed, it will put uninstall.bat file in application installation root.

Points of Interest

I am saving my time again from uninstalling any application from addremove programs utility.

Any type of suggestions are always welcome and if you have any doubts or problems, please contact me.

Enjoy it.

Please visit to my web space for some more articles at

Thank you.


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


About the Author

Hungry Mind
Web Developer
India India
I m a Graduate in Computer Science.
My hobies are to scratch new things from it's bottom and develop new thigs which can be useful for me and others.

So i got the Software developement the best stream where u can help others and u will be pampered with everything.

When i watch someone happy then i feel like that person is sharing my happiness and u know if someone is happy with u'r matters then that is the true person beyond everything for u.

So plz help others but first try to help u'r self then only u will enjoy helping others.
Good Luck.....

Please visit to my web space for some more articles,

Thank you.

You may also be interested in...


Comments and Discussions

GeneralCompleting This Solution - A Better Version Pin
kelvin199711-Nov-09 4:59
memberkelvin199711-Nov-09 4:59 
GeneralRe: Completing This Solution - A Better Version Pin
SohelElite17-Nov-09 21:43
memberSohelElite17-Nov-09 21:43 
GeneralGreate article Pin
pankaj.indore22-Oct-07 1:36
memberpankaj.indore22-Oct-07 1:36 
GeneralRe: Greate article Pin
Hungry Mind22-Oct-07 1:55
memberHungry Mind22-Oct-07 1:55 

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
Web01 | 2.8.170118.1 | Last Updated 3 Aug 2007
Article Copyright 2007 by Hungry Mind
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid