In the command line you can output the current directory using echo %CD%
like this this:
The Windows Scripting Host provides the ExpandEnvironmentalStrings
method which can be used like this:
Dim objWshShell : Set objWshShell = CreateObject("Wscript.Shell")
MsgBox objWshShell.ExpandEnvironmentStrings("%WINDIR%")
However, it doesn't work with %CD%
. It just returns the same value, %CD%
:
Dim objWshShell : Set objWshShell = CreateObject("Wscript.Shell")
MsgBox objWshShell.ExpandEnvironmentStrings("%CD%")
Why doesn't this work? I know there are other ways to get the current directory; this is just a curiousity.