This is in continuation to the last post where we saw how to read windows environment variables using VBScript. As mentioned in the last post, we can use the following preferred methods to achieve this :
- 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 ‘strEnvVarType’, the valid parameters for Environment are PROCESS, SYSTEM, USER and VOLATILE.
You can additionally specify the name of a specific environment variable using ‘strEnvVarName’ for example TEMP, PATH, PATHEXT, etc.