vbs 實現瞬間關閉多個系統程序

2021-08-29 15:19:18 字數 1908 閱讀 5593

'-------------建立臨時文字檔案檔案,把當前程序輸入該文字檔案之中並通過記事本開啟之

'---------同時把程序對應序號 和 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=1for 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

'--------把使用者輸入的序號列中相關的序號傳遞給乙個陣列 xs

xs=split(x,",",-1,1)

'-----------對使用者輸入的序號列進行校對,將重複序號標記為 -2,計算實際序號個數

for i=0 to ubound(xs) '---利用雙重迴圈將重複輸入的內容保留乙份,其他的標記為-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 '----把不真實可用的序號剔除並計算出其個數

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=0for 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

VBS批量關閉程序

每次下班的時候,都要關閉一大堆軟體,雖然說也就兩三分鐘的事兒,但能用 思想去搞定這兩三分鐘也是極好的。提公升為管理員許可權,否則無法乾掉system程序 set wshshell wscript.createobject wscript.shell if wscript.arguments.leng...

php實現多程序和關閉程序

一 php實現多程序 php有個pcntl fork的函式可以實現多程序,但要載入pcntl拓展,而且只有在linux下才能編譯這個拓展.先 arr 30000000 500000000 7000000000 8000000 foreach arr as key item else if pid k...

多程序的實現投票的vbs指令碼

複製 如下 獲得 wscript.exe 程序的數量 a 0 for nbswww.cppcns.comp each ps in getobject winmgmts root cim程式設計客棧v2 win32 process instances if ps.name wscript.exe th...