通过Vbscript终止命令提示符进程
我想通过VB脚本单击停止按钮来终止cmd.exe进程。它不起作用 如果我将子例程作为.vbs文件单独运行,则该子例程工作正常 我甚至尝试将子程序代码保存在一个单独的.vbs文件中&在我的html文件中调用它通过Vbscript终止命令提示符进程,vbscript,Vbscript,我想通过VB脚本单击停止按钮来终止cmd.exe进程。它不起作用 如果我将子例程作为.vbs文件单独运行,则该子例程工作正常 我甚至尝试将子程序代码保存在一个单独的.vbs文件中&在我的html文件中调用它 <html> <head> <SCRIPT LANGUAGE="VBScript"> Sub stopbtn_OnClick MsgBox "Mirabile visu." strComputer = "." strProcessToK
<html>
<head>
<SCRIPT LANGUAGE="VBScript">
Sub stopbtn_OnClick
MsgBox "Mirabile visu."
strComputer = "."
strProcessToKill = "cmd.exe"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")
count = 0
For Each objProcess in colProcess
objProcess.Terminate()
count = count + 1
Next
wscript.echo "Killed " & count & " instances of " & _
strProcessToKill & "on " & strComputer
End Sub
</SCRIPT>
</head>
<body>
<form name="stoprc">
<tr>
<td width="80"></td>
<td><input type="button" value="Stop" name="stopbtn" ></td>
</tr>
</form>
<body>
</html>
子站Btn_OnClick
MsgBox“Mirabile visu”
strComputer=“”
strProcessToKill=“cmd.exe”
设置objWMIService=GetObject(“winmgmts:_
&“{impersonationLevel=impersonate}.\\”\u
&strComputer&“\root\cimv2”)
设置colProcess=objWMIService.ExecQuery_
(“从Win32_进程中选择*,其中Name=”&strProcessToKill&“”)
计数=0
对于colProcess中的每个objProcess
objProcess.Terminate()
计数=计数+1
下一个
wscript.echo“已终止”&count&“的实例”&_
strProcessToKill&on&STRC计算机
端接头
由于明显的安全原因,您无法在浏览器沙箱中立即执行此操作,您可以尝试将服务域添加到IE中的“受信任站点”区域,或者如果您只需要一个UI@AlexK. +1,我认为您可以将您的评论作为答案发布。tskill.exe不能用于此目的吗?