Search code examples
visual-studio-2010visual-studiosetup-project

Visual Studio Setup Project: Kill Running Process On Uninstall


This is a setup for a program running in the taskbar. It starts every time the user logs in.

I cannot simply upgrade a program with a Visual Studio Setup, so I must first uninstall the previous version. (EDIT: It has to be a different version, in other words it has to be compiled at a different time. If it is the same version it gives the Repair/Remove dialogue.)

When I uninstall, I expect the installer to kill the previous instance, or ask the user to manually terminate it. Instead, it wants to restart it, so the new installation fails to launch the application.

Is there a setting to change this?


Solution

  • So I assume it cannot be done.

    My current workaround is execute a custom program on install, which executes a shell command to kill all running processes with the TASKKILL command. (Starting a batch file is also an option.)

    NOTE:

    • I have to do this on install. Doing this on uninstall makes no difference, because the uninstaller checks for running processes before performing the custom actions. Although I still have a running instance after install, at least the new installer will be able to start the latest version.
    • The InstallerClass option on the custom event properties must be false.

    EDIT: The only problem with this is that the installer starts a .vshost.exe instance of my "killer" app, and it restarts itself when killed. It only goes away once you log off the machine. Nothing breaks, but my inner perfectionist finds it annoying.

    EDIT: Another problem is that some virus programs may not like this, and you have to accept it as trusted.