All Properties
Method: WshShell.ExpandEnvironmentStrings
WshShell.
ExpandEnvironmentStrings
strString
The
ExpandEnvironmentStrings
method expands the environment variables in
strString
and returns the resulting string. Environment variables are case-insensitive and are enclosed by a pair of % characters. If an environment variable in
strString
is undefined, then it is left unchanged.
The following VBScript code illustrates the behavior of this method.
Code:
Set WshShell = CreateObject("WScript.Shell")
strOriginalString = "Windows is installed in %WinDir%. %XYZ% is undefined."
strExpandedString = WshShell.ExpandEnvironmentStrings(strOriginalString)
WScript.Echo "Before: " & strOriginalString
WScript.Echo "After: " & strExpandedString
Output:
Before: Windows is installed in %WinDir%. %XYZ% is undefined.
After: Windows is installed in C:\WINNT. %XYZ% is undefined.
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information