本帖最后由 hsyihao 于 2011-3-22 23:32 编辑
想写一个结束指定进程2分钟后关机的脚本,下面这个脚本能结束进程,但服务进程不行。请大家帮我看看,谢了ProcessClosePath("F:\bak\QQNetBar\QQNetBar.exe") ;进程
ProcessClosePath("F:\bak\sadfas\asdf.exe") ;进程
ProcessClosePath("D:\HintSoft\dfdafds\dingfeng\asdfay.exe") ;进程
ProcessClosePath("D:\HintSoft\asdfas\Bin\asdfsdfsr.exe") ;服务进程
ProcessClosePath("D:\HintSoft\asdfasd0\Bin\asddfasd.exe") ;服务进程
ProcessClosePath("D:\HintSoft\asdfasdf\Bin\asdfasdf.exe") ;服务进程
ProcessClosePath("D:\HintSoft\sadfasdf\Bin\asdfasdf.exe") ;服务进程
Func ProcessClosePath($Path)
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
这个是在坛子里找的win2003锁屏关机脚本;Sleep(120000);等待2分钟,注意,一定要在2分钟内锁定计算机,否则测试没意义
$result = DllCall("ntdll.dll","str","RtlAdjustPrivilege", "int",19, "bool",1, "bool",0, "bool*",0)
$result = DllCall("ntdll.dll","str","NtShutdownSystem", "int",2)
|