Monday 23 September 2013

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


No comments:

Post a Comment

Total Pageviews