How to terminate the process in vbscript
Here is the vbscript that will terminate or close all the processes with given name
In below script I am closing internet explorer process.
'Create a WMI object
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'get all processes with name iexplore.exe
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'iexplore.exe'")
'terminate each process
For Each objProcess in colProcessList
objProcess.Terminate()
Next
In below script I am closing internet explorer process.
'Create a WMI object
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'get all processes with name iexplore.exe
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'iexplore.exe'")
'terminate each process
For Each objProcess in colProcessList
objProcess.Terminate()
Next
0 comments:
Post a Comment