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?

link|improve this question

I wasn't quite understanding what you wanted - why can't you just use the %1%, %2% etc variables if you are passing parameters into the script? Is there some reason why you need to validate the path? – Helvick Aug 22 '10 at 16:33
feedback

2 Answers

up vote 2 down vote accepted

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

link|improve this answer
1  
This isn't an environment variable; it's merely a "pseudo-variable". Whenever you use those, keep in mind to delete an actual variable of that name before as their magic doesn't work when a variable with that name exists. – Joey Aug 22 '10 at 17:11
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.