Board index » Visual Studio » killing child processes
|
SkptngVanaB
|
killing child processes
Visual Studio369
I'm using a vbscript to Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("program.exe") Sometimes this program hangs, and I'd like it to timeout and be killed. I can do this with: oExec.Terminate() But "program.exe" spawns a child process which does not get killed. Is there a way to track the child processes spawned and/or kill them? I know the name of the process spawned, but there may be more than one parent/child pair running simultaneously, so I'm wary of the solutions I've quoted below. Any help? <qoute> From: Michael Harris (Please.Respond@To.NewsGroup) Subject: Re: "bWaitOnReturn" option for WshShell.Run method Newsgroups: microsoft.public.scripting.wsh Date: 2000/11/27 "...Is there a way of tracking which processes are spawned by other processes. ..." If you know that foo.exe will spawn an instance of bar.exe, you *could* use WMI it track the PIDs (Process IDs) of instances of bar.exe. For example, before executing foo.exe, record the PIDs (if any) of bar.exe instances. Execute foo.exe and recheck the PIDs for bar.exe instances. The one that is new is for the new instance of bar.exe spawned by foo.exe. There might even be a more direct way using WMI notification events but that would take a lot more time to research ;-)... I don't know if there is a generic technique available to script clients to track the child processes of an arbitrary parent process. If there is one it would probably involve WMI... -- Michael Harris Microsoft.MVP.Scripting -- mikhar@mvps.org Please do not email questions - post them to the newsgroup instead. -- "Andrew Britton" <andrewjbritton@hotmail.com>wrote in message QuoteAs a follow on, taking up Michael's point, what, if anything, can be done if Janak Sanariya wrote: QuoteI have script that kills a process but I need to modify it so that it also |
