#include <WinAPIEx.au3>
Local $sExeName = 'QQ.exe'
Local $sKillPath = 'C:\'
Local $aList = ProcessList()
Local $sAll = '', $KillPid, $i, $len = StringLen($sExeName) + 1
For $i = 1 To $aList[0][0]
$tmp = _WinAPI_GetProcessFileName($aList[$i][1])
If StringRight($tmp, $len) = '\' & $sExeName Then
$sAll &= $tmp & ' |' & $aList[$i][1] & @CRLF
If $tmp = $sKillPath & $sExeName Then $KillPid = $aList[$i][1]
EndIf
Next
Local $aList = StringRegExp($sAll, '\V+', 3)
If @error Then
MsgBox(48, '', $sExeName & ' 未运行')
ElseIf UBound($aList) = 1 Then
MsgBox(64, '', $sExeName & ' 仅有一个在运行:' & @LF & $sAll)
Else
If MsgBox(48 + 4, '', $sExeName & ' 有多个在运行:' & @LF & $sAll & @LF & @LF & '是否结束:' & $sKillPath & $sExeName) = 6 Then
If ProcessClose($KillPid) Then MsgBox(64, '', $sKillPath & $sExeName & ' 已结束')
EndIf
EndIf
|