In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to kill the specified process name in vbs. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Function KillProc (strProcName) On Error Resume Next Set objWMIService = GetObject ("winmgmts: {impersonationLevel=impersonate}!\\.\ root\ cimv2") Set arrProcesses = objWMIService.ExecQuery ("select * from win32_process where Name ='" & strProcName& "") For Each proccess In arrProcesses proccess.Terminate 0 NextEnd Function
VBS command-process operation code (detect process, end process)
/ / detect process name = "qq.exe" return value = IsProcess (process name) If return value = True ThenMessageBox "Discovery process" ElseIf return value = False ThenMessageBox "No process found" End If// detection process optimized code If IsProcess ("qq.exe") = True ThenMessageBox "discovery process" Else MessageBox "no discovery process" End If// detection process group = "qq.exe | notepad.exe" return value = IsProcessEx (process group) If return value = True ThenMessageBox "Discovery process" ElseIf return value = False ThenMessageBox "No process found" End If// Detection process Group optimized code If IsProcessEx ("qq.exe | notepad.exe") = True ThenMessageBox "Discovery process" Else MessageBox "No discovery process" End If// end process foreground execution process name = "qq.exe" Call CloseProcess (process name) 1) / / end process background execution process name = "qq.exe" Call CloseProcess (process name, 0) / end process group foreground execution process group = "qq.exe | notepad.exe" Call CloseProcessEx (process group, 1) / end process group background execution process group = "qq.exe | notepad.exe" Call CloseProcessEx (process group, 0) / / instance application execution 10 second timeout process name = "qq.exe" For 10Call CloseProcess (process name) 1) Delay 1000 return value = IsProcess (process name) If return value = False ThenExit ForEnd IfNextIf return value = True ThenMessageBox "end process failed" ElseMessageBox "end process succeeded" End If// instance Application terminates the optimized code executed by the foreground of the process (straight to loop) some processes cannot be detected by VBS, so close first and then detect DoCall CloseProcess ("qq.exe") 1) Delay 1000Loop While IsProcess ("qq.exe") = TrueMessageBox "end process successfully" / / instance application terminates process group background executes 10 second timeout process group = "qq.exe | notepad.exe" For 10Call CloseProcessEx (process group) 0) Delay 1000 return value = IsProcessEx (process group) If return value = False ThenExit ForEnd IfNextIf return value = True ThenMessageBox "end process failed" ElseMessageBox "end process successfully" End If// instance App ends the code optimized by the process group backend (straight to loop) some processes cannot be detected by VBS, so close first and then detect DoCall CloseProcessEx ("qq.exe | notepad.exe" 0) Delay 1000Loop While IsProcessEx ("qq.exe | notepad.exe") = TrueMessageBox "end process successfully" / function subroutine partial code / / detect process Function IsProcess (ExeName) Dim WMI, Obj, Objs,iIsProcess = FalseSet WMI = GetObject ("WinMgmts:") Set Objs = WMI.InstancesOf ("Win32_Process") For Each Obj In ObjsIf InStr (UCase (ExeName), UCase (Obj.Description) 0 ThenIsProcess = TrueExit ForEnd IfNextSet Objs = NothingSet WMI = NothingEnd Function// termination process Sub CloseProcess (ExeName) RunMode) dim wsSet ws = createobject ("Wscript.Shell") ws.run "cmd.exe / C Taskkill / f / im" & ExeName,RunModeSet ws = NothingEnd Sub// detection process group Function IsProcessEx (ExeName) Dim WMI, Obj, Objs,ProcessName,iIsProcessEx = FalseSet WMI = GetObject ("WinMgmts:") Set Objs = WMI.InstancesOf ("Win32_Process") ProcessName=Split (ExeName, "|") For Each Obj In ObjsFor item0 to UBound (ProcessName) If InStr (UCase (ProcessName (I)) UCase (Obj.Description) 0 ThenIsProcessEx = TrueExit ForEnd IfNextNextSet Objs = NothingSet WMI = NothingEnd Function// termination process group Sub CloseProcessEx (ExeName,RunMode) dim ws,ProcessName,CmdCode,iProcessName = Split (ExeName, "|") For item0 to UBound (ProcessName) CmdCode=CmdCode & "/ im" & ProcessName (I) NextSet ws = createobject ("Wscript.Shell") ws.run "cmd.exe / C Taskkill / f" & CmdCode RunModeSet ws = NothingEnd Sub this is the end of the article on "how vbs kills a specified process name". Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.