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

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?


Solution 1:

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

Solution 2:

The %CD% pseudo-environment variable contains the current working directory and is available within CMD\Batch files.

In your case a batchfile that just contains MyExe.exe %CD% will do what you want.