Site icon Automation Dojos

How To Read Windows Environment Variables With VBScript

Reading an environment variable is simple. There are a couple of methods available to do this but the main preferred ones are the below two :

  • Using the WSH Shell object
  • Using WMI’s Win32_Environment class

In the below example we would be using the WSH Shell’s Environment method.

For ‘envVarType’, the valid parameters for Environment are PROCESS, SYSTEM, USER and VOLATILE.

You can additionally specify the name of a specific environment variable using ‘envVarName’ for example TEMP, PATH, PATHEXT, etc.

Exit mobile version