查找指定文件夹在运行的进程并结束
目地为了网吧虚拟盘更新,当客户机要断开虚拟盘时老出现还有进程在运行无法断开的现象,现想做个类似于Unlocker一样的程序最好是无界面判断完自动结束其进程
[ 本帖最后由 ynygu 于 2008-8-30 19:45 编辑 ] 这不是根据路径结束进程吗?
UDF版发有了的。 根据文件路径关闭进程
ProcessClosePath("d:\\notepad.exe")
Func ProcessClosePath($Path)
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
页:
[1]