Pages - Menu

Thursday, January 3, 2019

How to terminate the process in vbscript


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

No comments:

Post a Comment