我目前有一些 AutoIT 代码将终止远程机器上的进程,但我需要找到一种方法来添加检查以查看进程是否首先运行。花了一些时间筛选 AutoIT 论坛和谷歌后,我不知所措。这是我目前拥有的:
Func EndProc()
$oWMIService = ObjGet("winmgmts:\\" & $ipAddress & "\root\CIMV2")
If Not IsObj($oWMIService) Then
MsgBox(48, "ERROR", "Couldn't locate the computer. Please make sure you've selected the correct computer and try again.")
Return
EndIf
Dim $handle, $colProc, $cProc
$cProc = $oWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE Name = "' & $ProcessToKill & '"')
For $oProc In $cProc
$oProc.Terminate()
Next
If $handle Then
Return $handle
Else
Return 0
EndIf
EndFunc ; Func EndProc()