根据文件路径结束进程
本帖最后由 lynfr8 于 2009-4-25 19:11 编辑echo Y |wmic PROCESS where ExecutablePath="D:\\Program Files\\Tencent\\qq\\QQ.exe"
delete
请教下用au3怎么来实现相同功能
已找到答案
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
$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 三恨写过一个UDF,
http://www.autoitx.com/forum.php?mod=viewthread&tid=1703&extra=page%3D5 感激ls的:face (23): 更新修正一下。直接输入正常路径就可以了。
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
:face (33):感激三恨
页:
[1]