Last active
March 9, 2023 11:03
-
-
Save adojos/4a4e8a757fe51a1cbba9cf34cbc95847 to your computer and use it in GitHub Desktop.
VBS: Read Windows Environment Variables #vbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ReadEnvVar(envVarType, envVarName) | |
Dim arrStrVar, strVar | |
Set objShell = CreateObject("WScript.Shell") | |
Set objEnv = objShell.Environment(envVarType) | |
WScript.Echo objEnv(envVarName) | |
arrStrVar = Split(objEnv(envVarName), ";") | |
For Each strVar In arrStrVar | |
WScript.Echo strVar | |
Next | |
Set objEnv = Nothing | |
Set objShell = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment