我目前有一些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()