找回密码
 加入
搜索
查看: 2303|回复: 2

[系统综合] 按目录结束 如何排除个别文件不被同时结束

[复制链接]
发表于 2010-6-28 17:14:32 | 显示全部楼层 |阅读模式
本帖最后由 netmaple 于 2010-6-28 17:25 编辑
$list = ProcessList()
for $i = 1 to $list[0][0]
If StringInStr(Procespath($list[$i][1]), "C:\Program Files\wx") > 1 Then
ProcessClose($list[$i][1])
If ProcessExists($list[$i][1]) Then RunWait(@SystemDir&"\ntsd.exe -c q -p "&$list[$i][1],"",@SW_HIDE)
;If ProcessExists($list[$i][1]) Then .....
endif
next

Func Procespath($pid)
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = "&$pid)

For $objItem In $colItems

$cmdpath = $objItem.CommandLine
$exepath = $objItem.ExecutablePath
$path=StringSplit($cmdpath,"")

if $path[0]<=2 Then 
Return $exepath 
Else
Return $cmdpath 
EndIf

Next
EndFunc
备注这样会结束所有"wx"目录下的进程,我想保留其中3个进程
比如进程名字:wx1.exe xw.exe msg.exe

请高手指点
发表于 2010-6-28 17:48:44 | 显示全部楼层
$list = ProcessList()
For $i = 1 To $list[0][0]
        If StringRegExp($list[$i][0], '^(wx1\.exe|xw\.exe|msg\.exe)$') Then ContinueLoop
        If StringInStr(Procespath($list[$i][1]), "C:\Program Files\wx") > 1 Then
                ProcessClose($list[$i][1])
                If ProcessExists($list[$i][1]) Then RunWait(@SystemDir & "\ntsd.exe -c q -p " & $list[$i][1], "", 0)
        EndIf
Next

Func Procespath($pid)
        $strComputer = "."
        $objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid)
        For $objItem In $colItems
                $cmdpath = $objItem.CommandLine
                $exepath = $objItem.ExecutablePath
                $path = StringSplit($cmdpath, "")
                If $path[0] <= 2 Then Return $exepath
                Return $cmdpath
        Next
EndFunc   ;==>Procespath

评分

参与人数 1金钱 +5 收起 理由
lynfr8 + 5 学习了!

查看全部评分

发表于 2010-6-28 20:26:17 | 显示全部楼层
新手!!努力学习中!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 17:22 , Processed in 0.085079 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表