返回环境变量的扩展值。
object.ExpandEnvironmentStrings(strString)
ExpandEnvironmentStrings 方法只扩展在 PROCESS 环境中定义的环境变量。环境变量名不区分大小写,其前后必须有 "%" 字符。
下面的代码扩展 Windows Directory 环境变量,并在消息框中显示它。
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "WinDir is " & WshShell.ExpandEnvironmentStrings(
"%WinDir%")
var WshShell = WScript.CreateObject("WScript.Shell");
WScript.Echo("WinDir is " + WshShell.ExpandEnvironmentStrings("%WinDir%"));