Windows – How to send the current working directory as an argument in windows

batch-filecommand-line-interfacewindowswindows 7

I want to send a path as an argument to an executable.
what I want to do something like this:

pushd some\folder
set x=cd
popd
MyExe.exe %x%

the problem is that the x variable is now equal to the string "cd" but what I want is to get the output of cd into x.
How do I do that?

Best Answer

Windows maintains the current directory in the environment variable %CD%.

echo %CD%  
c:\users\user
pushd c:\temp
echo %CD%
c:\temp
set X=%CD%
popd 
MyExe.exe %X%

will pass c:\temp to MyExe.exe