程序試驗環(huán)境為 windows xp_sp2,主要針對系統(tǒng)存在多個需要中斷進程的情況下,瞬間成批中斷進程。
復(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)建臨時文本文件文件,把當(dāng)前進程輸入該文本文件之中并通過記事本打開之 '---------同時把進程對應(yīng)序號 和 pid 傳遞給dictionary(d0)一份 filename=fs.GetTempName set f1=fs.CreateTextFile(filename,True) msg="序號"&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
'--------如果用戶取消了操作,就退出程序 If x="" then wscript.quit '--------把用戶輸入的序號列中相關(guān)的序號傳遞給一個數(shù)組 xs xs=Split(x,",",-1,1) '-----------對用戶輸入的序號列進行校對,將重復(fù)序號標記為 -2,計算實際序號個數(shù) For i=0 to ubound(xs) '---利用雙重循環(huán)將重復(fù)輸入的內(nèi)容保留一份,其他的標記為-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