Scripting Question

How to kill a task as part of MSI uninstall using a transform file?

06/13/2012 19331 views

I'm applying a transform on a vendor msi for the installation using wise package stuido 8. This application creates a task in the start up. Before the application can be uninstalled, that task needs to be killed. The command line to kill that task is "taskkill /IM Alertwatch.exe  My question is, where in my transform can I include that command line for it to launch during uninstall.  Thanks and I appreciate any help.

Answer Summary:
Stop the service first through service control table and the specify custom action to kill the process.
0 Comments   [ + ] Show comments


All Answers


1. Stage it before "Remove files" Sequence in installexecute sequence table.

2. You can also stage it before installfinalize.

Use the below condition to run the custom action during uninstall only.

If REMOVE~="All" then

Taskkill.exe /IM Alertwatch.exe



1. Killing the process before the files uninstallation will free the file if it in use.


2. before installfinalize: if the file is in use, windows installer will not uninstall it, instead it will add it to pending files actions and the file gets removed when the user reboots his machine next time. This will leave the directory on the machine where file was located.

Answered 06/13/2012 by: Propac
White Belt


Using the Taskkill.exe /IM Alertwatch.exe command directly to kill process in custom action during uninstallation/installation prompts a command prompt when it is executing this command line.. Some process takes more time to terminate itself, So, it is always better to use VBScript to do these type of stuffs. So It wont distrub the end users by prompting a command prompt at the time of uninstallation.

Answered 06/14/2012 by: jagadeish
Red Belt


I will make your work easy. :)

Use the script here:


Create a Customa Action and place it just after InstallFinalize and Run it in Deffered execution in System Context. Put condition as REMOVE~="ALL"

Answered 06/15/2012 by: piyushnasa
Red Belt


Killing a process should be the last option. You can stop the service related to this process using the service control table. In case it fails create a custom action and use the pskill.exe from microsoft sys-internals to kill the process.

Answered 06/13/2012 by: adilrathore
4th Degree Black Belt

This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ