Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to kill Processes with scripts ? (wmi or something else)

Status
Not open for further replies.

swordbarth

Programmer
Oct 12, 2001
3
CH
I found a Script that shows all Win32 Processes.
My Question is: Can i Kill Processes with WMI too??
wsf-file:
--------------------->
<job>
<script language=&quot;JavaScript&quot;>
var e= new Enumerator(GetObject(&quot;winmgmts:&quot;).InstancesOf(&quot;Win32_process&quot;))

var sMsg = &quot;Processes\n&quot;;
debugger;
for (;!e.atEnd();e.moveNext())
{
   var Process = e.item();  
sMsg += Process.Name + &quot;\t&quot; + Process.processid + &quot;\n&quot;;
}
WScript.echo (sMsg);
stop
</script>
</job>
 
Yes, you can terminate processes on any machine you have admin rights to using the following code snippet.

Code:
For each Process in GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!//TEST01&quot;).ExecQuery
(&quot;select * from Win32_Process where Name='notepad.exe'&quot;)

	Process.Terminate
	'wscript.echo Process.Name & &quot; is &quot; & Process.ProcessId
Next

I would personally be leary of using it, but there it is.

Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top