Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Kill processes (using Javascript) on a 64-bits machine (Windows Vista, 7, 8, 8.1)

$
0
0

Hi everyone. I have a simple VBScript sample that kills a process by name. It works fine on every OS, X86 and 64 bits :

---------------------------kill process sample----------------------------------------

Set wsh = CreateObject("Wscript.Shell")

wsh.Run "calc.exe",1

Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
For each Process in Processes
Select Case LCase(Process.Name)
Case "calc.exe" 
Process.Terminate(1)

---------------------------------------------------------------------------------------------

I tried the "for" loop, the "forEach" loop and "switch" in javascript but none of them work like in VBScript.

Could anyone help me converting this script sample to javascript, since VBScript became obsolete and God knows whether it will be available for HTA applications and Windows Script Host files in the near future.

Thanks a lot in advance.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>