Thursday, January 3, 2019


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

Related Posts:

  • Types of variables in Vbscript Types of variables in Vbscript Variables are storage locations in memory where we can store the the values.In vb script there are 3 types of variables. Scalar  - contains only one value. Array - contains many val… Read More
  • What are the different operators in vbscript? What are the different operators in vbscript? At broad level there are 3 kinds of operators as mentioned below. Arithmetic Operators Comparison Operators Logical Operators Arithmetic Operators in the order of pre… Read More
  • Classes in VBScript Classes in VBScript Here is an example that shows how we can create a class in QTP. Once we define the class, we can create its objects and then access its method and properties. 'declare the class book. Class Bo… Read More
  • Error handling in VBScript Error handling in VBScript VBScript provides below statements and keywords to handle errors. on error resume next Err object - err.description, err.number Sample code to handle the error is given below If er… Read More
  • Data Types in vbscript Data Types in vbscript In vb script all variables are initialized with the data type called variant. But we can have below sub-types in vb script. In below table we have mentioned all sub data types in vb sc… Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

151,628

Blog Archive