更新修正一下。直接输入正常路径就可以了。
ProcessClosePath("d:\notepad.exe")
Func ProcessClosePath($Path)
;作用:根据程序路径结束进程
;返回:当WMI对象不存在,返回错误值1
;作者:叁恨居士
;版权:www.autoitx.com
;BLOG: www.lunhui.net.cn
Local $wbemFlagReturnImmediately
Local $wbemFlagForwardOnly
Local $strComputer,$objWMIService
Local $colItems,$objItem
$strComputer = "localhost"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$Path= StringReplace($Path,"\","\\")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Process Where ExecutablePath="'&$Path&'"', "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
$objItem.Terminate()
Next
Else
SetError(1)
Endif
EndFunc
|