views:

1258

answers:

3

Hi,

Can anyone explain to me how to create a uninstall command for a Windows-based application in the Application Folder when creating a new setup project in visual studio 2008.

I've found info on the net but nothing helping me so far. If you could supply me with links or instructions it would be great.

Thanks.

+1  A: 

The command line for uninstalling using msiexec :

msiexec /uninstall {GUID}

{GUID} is the Product Code of the setup package and you can find that in your Setup Project Properties. The uninstall program can be as simple as a bacth with that command or maybe a separate application, executing the command and performing addional custom cleaning.

L.E. Also, here is Microsoft's online documentation for msiexec.

L.E. Good article giving code snippet for creating a C# application that performs the uninstall

AlexDrenea
+1  A: 

In Visual Studio.NET:

Ø File > Add Project > New Project > Setup & Deployment Project > Setup Project (Enter name and location)

Ø Add (right-click in Application Folder > Add > Project Output):

· Primary Output

Ø If an error occurs about files that should be excluded > In Solution Explorer select your Setup project > Exclude those files (right-click > exclude)

Ø Build > Build ’name project’

In Windows:

Ø Create an Uninstall.bat file containing: C:\WINDOWS\system32\MsiExec.exe /I{productcode}

(Path depends of your Windows version, check where your system32 folder is located)

(You’ll find the productcode in Visual Studio.NET > Tab Properties in the setup project you’ve just created)

Ø Open the setup project in Visual Studio.NET if you closed it

Ø Add (right-click in Application Folder):

· Add > Project Output > File > Uninstall.bat

· Create New Shortcut > Application Folder > Primary Output (enter a name)

· Create New Shortcut > Application Folder > Uninstall.bat (enter a name)

· Add > File > add .ico files you want to use for the shortcuts

Ø Shortcuts properties > ‘icon’ property (use the icons you’ve just added)

Ø Move the shortcuts to User’s Desktop/User’s Programs Menu (you can also create subfolders)

Ø Build > Rebuild ’name project’

The setup is ready now. You can install via Setup.exe (default it’s located under the folder ‘Debug’, you can change it in Visual Studio.NET - right-click your setup project > properties > Output file name). The shortcuts will be added automatically in the coresponding folders (desktop/start menu).

You can uninstall the program via Uninstall.bat (or via shortcut naar Uninstall.bat)

Samiksha
Hi, I'm struggling to find the productcode in visual studio 2008. can you be a bit more specific as to where i can find it. Thanks
Domitius
A: 

msiexec /x {PRODUCT CODE} this will remove all file from folder where the application was installed. But i also want to delete folder in MY Document which was created at the time of installation how can i achieve that.

SohelElite