RE: Terminating a Process Tree
From: florence (florence_at_discussions.microsoft.com)
Date: 01/18/05
- Next message: deadmetal: "RE: Terminating a Process Tree"
- Previous message: deadmetal: "Terminating a Process Tree"
- In reply to: deadmetal: "Terminating a Process Tree"
- Next in thread: deadmetal: "RE: Terminating a Process Tree"
- Reply: deadmetal: "RE: Terminating a Process Tree"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 18 Jan 2005 06:43:05 -0800
Hi,
This should to it, though I haven't tested :
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'calc.exe'")
For Each objProcess in colProcessList
set colChildrenList = objWMIService.ExecQuery _
("Select * from Win32_Process Where ParentProcessID = " &
objProcess.ProcessID)
For Each objChild in colChildrenList
objChild.Terminate()
next
objProcess.Terminate()
Next
Flo
"deadmetal" wrote:
> Hello There
>
> I'm using the following code to script the termination of a process, but I
> was wondering if someone would be kind enough to help me re-write this so
> that it will terminate any child processes as well, I would really appreciate
> it
>
> Best Regards
>
> Gary
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,(debug)}!\\" & strComputer &
> "\root\cimv2")
>
> Set colProcessList = objWMIService.ExecQuery _
> ("Select * from Win32_Process Where Name = 'calc.exe'")
>
> For Each objProcess in colProcessList
> objProcess.Terminate()
> Next
>
- Next message: deadmetal: "RE: Terminating a Process Tree"
- Previous message: deadmetal: "Terminating a Process Tree"
- In reply to: deadmetal: "Terminating a Process Tree"
- Next in thread: deadmetal: "RE: Terminating a Process Tree"
- Reply: deadmetal: "RE: Terminating a Process Tree"
- Messages sorted by: [ date ] [ thread ]