简体   繁体   English

通过javascript停止cmd.exe或calc.exe进程(Windows Process)

[英]Stop cmd.exe or calc.exe process(Windows Process) by javascript

Hello guys how can we stop a cmd.exe or calc.exe windows process through a java script function? 大家好,我们如何通过Java脚本功能停止cmd.exe或calc.exe Windows进程? I am calling a javascript function on button click on a web page. 我在网页上单击按钮时调用了javascript函数。

I tried the below code but it didn't work. 我尝试了下面的代码,但是没有用。

   function CloseClips() {

            var wmi = GetObject("WinMgmts:").InstancesOf("Win32_Process");
            var procs = wmi.execquery("select * from Win32_process where Name='CLIPSDOS64.exe'");
            var enumProcs = new Enumerator(procs);
            for (; !enumProcs.atEnd(); enumProcs.moveNext()) {
                var p = enumProcs.item();
                p.Terminate();
            }                        
        }

I am Getting the following error: Uncaught ReferenceError: GetObject is not defined at CloseClips 我收到以下错误:未捕获的ReferenceError:在CloseClips上未定义GetObject

It seems you are missing connection to the ManagmentScope ie before GetObject(...): 似乎您缺少与ManagmentScope的连接,即在GetObject(...)之前:

for your local machine (for remote you will have to use ConnectionOptions with user/pass): 对于本地计算机(对于远程计算机,必须将ConnectionOptions与user / pass一起使用):

ManagmentScope scope = new ManagmentScope("\\\\localhost\\root\\cimv2");
scope.connect();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM