1

我需要一个 .vbs 文件来检查特定进程是否处于活动状态并(如果是)终止它。

4

2 回答 2

0

和这个线程一样吗?

如何使用 VBScript 终止进程

除了您只需更改以下行:

Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Process.exe'")

Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & strMyProcess  & "'")
于 2012-10-20T07:45:43.470 回答
0
    myProcess="chrome.exe"                     'repleace chrome.exe with your process name
    Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")
    For Each Process In Processes
        If StrComp(Process.Name, myProcess, vbTextCompare) = 0 Then 'check if process exist
           Process.Terminate()                                   'kill the process you find
        End If
    Next
于 2018-09-28T22:48:33.170 回答