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:

  • What is Windows Script Host? What is Windows Script Host? WSH is a scripting host for Windows Script compatible scripting engines.WSH supports various scripting languages like vbscript, javascript, python etc.You can do below operations using WSH… Read More
  • What is WMI? What is WMI?  WMI and Win32 classes WMI stands for Windows Management Instrumentation. This is used to access system hardware and software features. It provides very powerful API to perform tasks like starting pr… 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
  • 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 nameIn below script I am closing internet explorer process.'Create a WMI objectstrComputer … Read More
  • How to create a word document using vbscript How to create a word document using vbscript ' Create and Save a Word Document'Create the Word objectSet objWord = CreateObject("Word.Application")'Set the caption of the WordobjWord.Caption = "Welcome to Automated Wo… Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

150,585

Blog Archive