In a Visual Studio setup project, How do I generate an uninstall script?

后端 未结 8 1580
无人及你
无人及你 2020-12-02 06:14

I have a Visual Studio setup project. Upon installation, it creates an uninstall batch file in the application folder. IF the user wants to uninstall the product, he can g

8条回答
  •  抹茶落季
    2020-12-02 06:36

    I realize this question has already been answered, but what I did was create a batch file with the following content:

    start msiexec.exe /x %1
    

    Using "start" prevents the command prompt from staying open during the uninstallation process and the %1 is replaced by the first argument you pass to the batch file when executing it.

    I added the batch file to the application folder and created a menu shortcut that points to the batch file. If you right click the shortcut and select Properties Window. In there, add the following text to the Arguments property:

    [ProductCode]
    

    After building and running the installer, you'll have a start menu shortcut that calls the batch file and passes the product code as it was when that version of the application was built. The user will then see a prompt asking if the product should be uninstalled.

    The only downside of this solution is that if the user browses to the application folder and double clicks the batch file, the uninstaller will give an error that the install package does not exist.

提交回复
热议问题