Thursday, January 3, 2019


How to read the environment variables in your system in vbscript?


You can read the system variables using below program


       'Create the WMI object
strComputer = "."
Set objWMIService = GetObject("winmgmts:"  _
           & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

      'get all variables using Win32_Environment Class.
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")

       'Enumerate each variable
For Each objItem in colItems
str = str & objItem.Name &  " ----------------->  " & objItem.VariableValue & vbcrlf
Next

Msgbox str



Related Posts:

  • 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
  • Difference between procedures and functions in vb script Difference between procedures and functions in vb script Major difference between procedures and functions in vb script is that procedures can not return the value but functions can return the value.Procedure Example… Read More
  • String functions in vbscript String functions in vbscript Below is the list of string functions in vb script lcase ucase len left right mid ltrim rtrim trim replace strreverse string Instr Instrrev strcomp We are going to have a look at each St… Read More
  • Sub Procedures in VBScript Sub Procedures in VBScript Sub procedures are used to perform the specific task. Sub procedures are used to increase the reusability of the code. Simple example of the procedure Suppose you want to find the sum of … Read More
  • Maths functions in vbscript Maths functions in vbscript Below is the list of all maths functions in vb script Abs  Atn  Cos  Exp  Fix  Int  Log  Rnd  Sgn  Sin  Sqr  Tan  round Let us … Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

151,681

Blog Archive