用vbs实现的瞬间关闭多个系统进程的脚本

2019-01-16 05:36:41刘景俊

w=0 '----把不真实可用的序号剔除并计算出其个数 
For i=0 To UBound(xs) 
If d0.Exists(xs(i))=False Then  
     xs(i)="-2" 
     w=w+1 
End If 
Next 

w=(UBound(xs)+1-w)    '---得出可用的序号个数 
'------------如果序列中没有输入任何序号就退出程序 
If w=0 Then 
MsgBox "需要中断的进程列表为空!" 
WScript.Quit 
End If 

'-------------根据用户输入信息中断相应进程 
m=0 
For i=0 To UBound(xs) 
If xs(i) <> "-2" then '---只有真实可用的序号才参与循环 
For Each p In pro_s 
    If Trim(p.handle)=trim(d0(xs(i))) Then '---如果进程pid号码正是需要中断的就尝试中断 
     p_name=p.name 
     pd=p.terminate() 
     If pd=0 Then '---判断中断进程的尝试是否成功 
      msg=p_name&" 进程中断成功!" 
      m=m+1 
     Else 
      msg=p_name&" 进程中断失败!" 
     End If 
     os.popup msg,1,"通知",64+0 
    End If 
Next 
end if 
Next 

os.popup    w&"个目标进程,已经中断了"&m&"个" ,5,"通知",64+0 
WScript.quit