I can’t figure out how to use the winmgmts object in JavaScript/JScript.
Here is how I used it in VBScript:
[code]set wmi = getobject(“winmgmts:”)
set cmd = wmi.execquery(“select * from Win32_Process where name = ‘cmd.exe'”)
for each process in cmd
process.terminate
next
That code will kill CMD just fine, but I tried to duplicate it in JavaScript/JScript and it didn’t work. Here is what I used:
[code]var wmi = GetObject(“winmgmts:”);
var cmd = wmi.execquery(“select * from Win32_Process where name = ‘cmd.exe'”);
for (process in cmd) {
process.terminate();
}
It gave me no errors but did not close CMD.
I can’t find this answer ANYWHERE on the internet, so if anyone knows it PLEASE tell me.