vbscript – Why doesnt WScript.Shell.ExpandEnvironmentStrings work with %CD%?
%CD% is a CMD-builtin automatic variable, not an environment variable like
%USERNAME%. It can only be used within CMD, e.g.
cmd /c echo %CD%
Same goes for the variables
If you want the current working directory in VBScript you need to use the
CurrentDirectory property of the
Set sh = CreateObject(WScript.Shell) WScript.Echo sh.CurrentDirectory
or expand the path of the directory
Set fso = CreateObject(Scripting.FileSystemObject) WScript.Echo fso.GetAbsolutePathName(.)