I have not been able to find an example of seeing what was running and being able to end the running tasks on a remote system. does anyone have any ideas?
You want to look up WMI win32_Process. That is what I use. The following code with get the running procs, but not kill them. I have not worked on that part yet. But this is a start:
strComputer = 10.10.10.10
Set oWmi = GetObject("winmgmts:{impersonationlevel=impersonate}!\\"&strComputer&"\root\cimv2"
query = "Select * from Win32_Process"
Set wql = oWmi.execQuery(query)
For Each item In wql
WScript.Echo(item.name)
next
Set wql = Nothing
Set owmi = Nothing
But i would not do a test run with the script as written since it will kill EVERY task running. I was looking for Multiple instances of a paticular task and when i saw your example i remembered the stock examples of how to find a specific running task. then i just added the .terminate() at the end of my named object, and it works.
thanks
Using your example, here is the finished code below:
strComputer = 10.10.10.10
Set oWmi = GetObject("winmgmts:{impersonationlevel=impersonate}!\\"&strComputer&"\root\cimv2"
query = "Select * from Win32_Process Where name = 'notepad.exe'"
Set wql = oWmi.execQuery(query)
For Each item In wql
'WScript.Echo(item.name)
item.terminate()
next
Set wql = Nothing
Set owmi = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.