Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using vbs to realize the script of instantly shutting down multiple system processes

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the script of instantly closing multiple system processes using vbs," interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn the script of "instantly closing multiple system processes using vbs"!

The program test environment is windows xp_sp2, which is mainly aimed at the situation that there are many processes that need to be interrupted in the system, and the process is interrupted instantaneously.

The copy code is as follows:

'----------------------------------------------------------------------------------

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")

'---------------Create temporary text file, enter current process into text file and open it via Notepad

'--------At the same time, pass the process corresponding serial number and pid to dictionary(d0)

filename=fs.GetTempName

set f1=fs.CreateTextFile(filename,True)

msg="Sequence"&vbTab&"Name"&vbTab&"PID"&vbTab&"Program File"&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

'-------------Wait for the user to enter the serial number column related to the process to be interrupted, close and delete the temporary text file after confirmation

x=InputBox("Please follow the contents of"&filename&""+Chr(10)+ _

"Select the corresponding sequence number of the process that needs to be interrupted at the same time: "+Chr(10)+ _

"(Sequence numbers separated by ',' e.g.'1,3,5,7,11')","Select")

os.AppActivate filename&" -Notepad"

os.SendKeys "%fx"

WScript.Sleep 500

fs.DeleteFile filename

'--------If the user cancels, exit the program

If x="" then wscript.quit

'--------Pass the relevant sequence number in the sequence number column entered by the user to an array xs

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

'-----------Collate the serial number column entered by the user, mark the repeated serial number as-2, and calculate the actual number of serial numbers

For i=0 to ubound(xs) '---Use double loop to keep one copy of duplicate input and mark the others as-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 '----Eliminate the unreal and usable serial numbers and calculate their number

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) '---Gets the number of serial numbers available

'------------

If w=0 Then

MsgBox "Empty list of processes to interrupt! "

WScript.Quit

End If

'-------------Interrupts the process according to user input information

m=0

For i=0 To UBound(xs)

If xs(i) "-2" then '---Only truly available serial numbers participate in the loop

For Each p In pro_s

If Trim(p.handle)=trim(d0(xs(i))) Then '---Try to interrupt if the process pid number is exactly what needs to be interrupted

p_name=p.name

pd=p.terminate()

If pd=0 Then '---Determine if the attempt to interrupt the process was successful

msg=p_name&"Process interrupt succeeded! "

m=m+1

Else

msg=p_name&"Process interrupt failed! "

End If

os.popup msg,1, Notification, 64 +0

End If

Next

end if

Next

os.popup w&"target processes,"&m&"interrupted," 5,"notification," 64 +0

WScript.quit

At this point, I believe that we have a deeper understanding of "the use of vbs to achieve the instant closure of multiple system processes script," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report