/build/static/layout/Breadcrumb_cap_w.png

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)

Posted by: anonymous_9363 14 years ago
Red Belt
0
You need to add a Custom Action, conditioned to run only during an uninstall (REMOVE~="ALL"). You'll find your best option is a VBScript-driven CA, as there are a quadzillion examples of scripts around which kill processes. Make sure, however, that any script you use is properly error-trapped.
Posted by: airwolf 14 years ago
Red Belt
0
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
Blue Belt
0
Cheers thanks. I know if I want a custom action at install time where I did not create the msi, I call it with a transform, I can't call a transform at uninstall?
Posted by: PackageExpert 14 years ago
Blue Belt
0
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.
Posted by: shakeela511 14 years ago
Yellow Belt
0
Hi,
Before uninstallation check the application is running
TASKLIST | FINDSTR /I "application.exe"
if the application is running , kill the application and uninstall.. I hope it will help you
Posted by: blade2 14 years ago
Blue Belt
0
ok cheers, now I get it. sorry a bit fuzzy on VBSCAB's reply.

Thanks
Posted by: anonymous_9363 14 years ago
Red Belt
0
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
Yellow Belt
0
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]
Posted by: anonymous_9363 14 years ago
Red Belt
0
Exactly so.
Posted by: blade2 14 years ago
Blue Belt
0
Thanks for your help guys. I have cracked it. I would have done as VBSCAB suggested however my process has a different PID each time it runs, so I don't see how I could.
Posted by: PackageExpert 14 years ago
Blue Belt
0
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..



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
Red Belt
0
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.
Posted by: andys0123 14 years ago
Orange Senior Belt
0
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.
Posted by: anonymous_9363 14 years ago
Red Belt
0
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
Orange Senior Belt
0
Hence the VBScript just shelling out to run PSList & PSKill - not running from a batch file. Not an ideal solution, but it works exactly a required.
Posted by: AngelD 14 years ago
Red Belt
0
If the process (file) is installed by the package then I would also (before executing the kill) get the path of the file and use that in the wmi query to make sure the process is part of the package and not any "random" process.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
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