欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用vbs實(shí)現(xiàn)的瞬間關(guān)閉多個(gè)系統(tǒng)進(jìn)程的腳本

 更新時(shí)間:2008年06月20日 19:24:50   作者:  
程序利用 vbs 的wmi 、scripting.filesystemobject、shell.application、scripting.dictionary、wscript.shell的相關(guān)功能功能實(shí)現(xiàn)將當(dāng)前進(jìn)程列表顯示在一個(gè)文本文件中,通過(guò)用戶界面的選擇,確定需要瞬間中斷的進(jìn)程列表,然后中斷之。
程序試驗(yàn)環(huán)境為 windows xp_sp2,主要針對(duì)系統(tǒng)存在多個(gè)需要中斷進(jìn)程的情況下,瞬間成批中斷進(jìn)程。
復(fù)制代碼 代碼如下:

'---------------------------------------------------------------------------------- 
On Error Resume next 
Set fs=CreateObject("scripting.filesystemobject") 
Set os=CreateObject("wscript.shell") 
Set os0=createobject("shell.application") 
Set d0=CreateObject("scripting.dictionary") 
Set wmi=GetObject("winmgmts:\\.") 
Set pro_s=wmi.instancesof("win32_process") 

'-------------創(chuàng)建臨時(shí)文本文件文件,把當(dāng)前進(jìn)程輸入該文本文件之中并通過(guò)記事本打開(kāi)之 
'---------同時(shí)把進(jìn)程對(duì)應(yīng)序號(hào) 和 pid 傳遞給dictionary(d0)一份 
filename=fs.GetTempName 
set f1=fs.CreateTextFile(filename,True) 
msg="序號(hào)"&vbTab&"名稱"&vbTab&"PID"&vbTab&"程序文件"&vbtab&now&Chr(10) 
f1.Writeline(msg) 
n=1 
For Each p In pro_s 
f1.WriteLine(n&". "&p.name&"    ,    "&p.handle&"    ,    "&p.commandline&Chr(10)) 
d0.Add ""&n,Trim(p.handle) 
n=n+1 
Next 
f1.Close 
os0.MinimizeAll 
os.Exec "notepad.exe "&filename 
wscript.sleep 500 

'--------------等待用戶輸入欲中斷的進(jìn)程相關(guān)的序號(hào)列,確定之后關(guān)閉并刪除臨時(shí)文本文件 
x=InputBox("請(qǐng)根據(jù)"&filename&"中的內(nèi)容"+Chr(10)+ _ 
     "選擇需要同時(shí)中斷的進(jìn)程對(duì)應(yīng)序號(hào):"+Chr(10)+ _ 
     "(序號(hào)之間用','間隔 例如:'1,3,5,7,11')","選擇") 
os.AppActivate filename&" - 記事本" 
os.SendKeys "%fx" 
WScript.Sleep 500 
fs.DeleteFile filename 

'--------如果用戶取消了操作,就退出程序 
If x="" then wscript.quit 
'--------把用戶輸入的序號(hào)列中相關(guān)的序號(hào)傳遞給一個(gè)數(shù)組 xs 
xs=Split(x,",",-1,1) 
'-----------對(duì)用戶輸入的序號(hào)列進(jìn)行校對(duì),將重復(fù)序號(hào)標(biāo)記為 -2,計(jì)算實(shí)際序號(hào)個(gè)數(shù) 
For i=0 to ubound(xs) '---利用雙重循環(huán)將重復(fù)輸入的內(nèi)容保留一份,其他的標(biāo)記為-1 
for n=0 to ubound(xs) 
    if n=i then  
     n=n+1 
     if n>ubound(xs) then exit for 
    end if 
    if Trim(xs(n))=Trim(xs(i)) Or _ 
     Trim(xs(n))="" Then  
     xs(n)="-1" 
    end If 
next 
Next 

w=0 '----把不真實(shí)可用的序號(hào)剔除并計(jì)算出其個(gè)數(shù) 
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)    '---得出可用的序號(hào)個(gè)數(shù) 
'------------如果序列中沒(méi)有輸入任何序號(hào)就退出程序 
If w=0 Then 
MsgBox "需要中斷的進(jìn)程列表為空!" 
WScript.Quit 
End If 

'-------------根據(jù)用戶輸入信息中斷相應(yīng)進(jìn)程 
m=0 
For i=0 To UBound(xs) 
If xs(i) <> "-2" then '---只有真實(shí)可用的序號(hào)才參與循環(huán) 
For Each p In pro_s 
    If Trim(p.handle)=trim(d0(xs(i))) Then '---如果進(jìn)程pid號(hào)碼正是需要中斷的就嘗試中斷 
     p_name=p.name 
     pd=p.terminate() 
     If pd=0 Then '---判斷中斷進(jìn)程的嘗試是否成功 
      msg=p_name&" 進(jìn)程中斷成功!" 
      m=m+1 
     Else 
      msg=p_name&" 進(jìn)程中斷失敗!" 
     End If 
     os.popup msg,1,"通知",64+0 
    End If 
Next 
end if 
Next 

os.popup    w&"個(gè)目標(biāo)進(jìn)程,已經(jīng)中斷了"&m&"個(gè)" ,5,"通知",64+0 
WScript.quit 


相關(guān)文章

最新評(píng)論