Search code examples
.netvisual-studiodeploymentsetup-projectuninstallation

.NET setup project and uninstaller


I have created a VS setup project for my app. It install the app to user-defined location and creates several shortcuts in the start menu. It also creates an entry in Control Panel/Add or Remove Programs that can be used to uninstall the application.

I would like to know if there is a way to create a start menu entry (next to other entries created by setup) that could uninstall my app.

So far I found one solution but it's pain to use: I have created uninstall.bat file that I deploy in my app folder and I'm adding a shortcut to this file. Contents of the *.bat looks like this:

@echo off
msiexec /x {0B02B2AB-12C6-4548-BF90-F754372B0D36}

What I don't like about this solution is that every time I update a product code of my app (I'm doing that whenever I update my app version as VS suggests) I have to manually edit this file before building setup project and type correct new product code.

Does anyone knows a simpler way of adding uninstaller to the app?


Solution

  • You can edit the .bat file to accept an argument.

    @echo off
    msiexec /x %1
    

    In the setup project, where you define the shortcut, add the [ProductCode] property as the argument.