kill a process before uninstall an app
Any tips on how to do this? I did not create the MSI, and it wont uninstal unless a process is killed first.
0 Comments
[ + ] Show comments
Answers (16)
Please log in to answer
Posted by:
anonymous_9363
15 years ago
Posted by:
airwolf
14 years ago
You could also write a simple AutoIT script to detect and kill the process before it runs the installer.
Posted by:
blade2
14 years ago
Posted by:
PackageExpert
14 years ago
If you have a vendor MSI then you should create a transform and add the custom action to Kill Process in the transform. As VBScab mentioned it should be set with condition REMOVE~="ALL" which will run during uninstall.
I usually sequence if before AppSearch with a Execution Property set to Synchronous and Execution Option set to Immediate.
I usually sequence if before AppSearch with a Execution Property set to Synchronous and Execution Option set to Immediate.
Posted by:
shakeela511
14 years ago
Posted by:
anonymous_9363
14 years ago
TASKLIST | FINDSTR /I "application.exe"Too messy. Most of the process-killing scripts around use the WMI object to enumerate the process list and, when the target process is found, get its process ID, using that to terminate the process. Avoid those scripts which kill named processes: always use the process ID. You can hopefully work out why.
Posted by:
shakeela511
14 years ago
Hi VBScab,
If we kill the process , by process name, there is danger of termination of other processes related to the application also.
If we kill the process by using process id, which unique for the application, we can avoid above problem.
Thatswhy we cant use processnames to kill the application . Is it?[:o]
If we kill the process , by process name, there is danger of termination of other processes related to the application also.
If we kill the process by using process id, which unique for the application, we can avoid above problem.
Thatswhy we cant use processnames to kill the application . Is it?[:o]
Posted by:
blade2
14 years ago
Posted by:
PackageExpert
14 years ago
Then I guess you have no choice but to use the Process Name unless anyone else can come up with a better solution. Here's an example, just replace the exe..
Make sure that terminating this process has no linkage to the others as mentioned by VBScab and Shakeela511
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'YourRunningApplication.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
Make sure that terminating this process has no linkage to the others as mentioned by VBScab and Shakeela511
Posted by:
anonymous_9363
14 years ago
I changed my mind. My mind was on process creation, as I'm building a script at the moment which creates and monitors a process's execution. For that, I need the process ID, as there may be another instance (or instances) running.
For process termination, it wouldn't matter if there's more than one instance since, if you need to kill Fred.EXE in order to replace it, you would clearly need to kill all instances of it.
For process termination, it wouldn't matter if there's more than one instance since, if you need to kill Fred.EXE in order to replace it, you would clearly need to kill all instances of it.
Posted by:
andys0123
14 years ago
One way of killing the process is to download PStool from Sysinternals & create a Transform containing a Custom Action VBScript which uses PSList & PSKill. The script should call PSlist to list all the processes to a file, parse the file to find the relevant Process Name and thus its Proces ID, and then call PSKill to kill that process ID.
To call the uninstall using the new Transform, check out my comments in http://itninja.com/question/can't-apply-transform-with-msi-reinstall.
To call the uninstall using the new Transform, check out my comments in http://itninja.com/question/can't-apply-transform-with-msi-reinstall.
Posted by:
anonymous_9363
14 years ago
Without question, command line tools, especially ones of quality such as those from SysInternals, work. However, they are more suited to one-off - what I call QAD (Quick And Dirty) - usage. For a more professional approach, script is the way to go, since to describe error-trapping and conditional branching in batch/command files as "primitive" would be more than kind.
Posted by:
andys0123
14 years ago
Posted by:
AngelD
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.