I'm trying to run this code:

Set a = "c:\a"
set b = "c:\b"
xcopy /d /y %a  %b

But I don't know why it cannot recognize the second path.

The export in cmd is like xcopy /d /y c:\a

Does anyone know why?

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

You should not have spaces before and after the "=" sign when setting the variables. And as Ignacio said, variables should end and start with %

So this should work correctly:

set a="c:\a"
set b="c:\b"
xcopy /d /y %a% %b%
link|improve this answer
:X :X :X luv u. It work fine,Thanks... – rima Nov 4 '10 at 9:27
feedback

Batch variables begin and end with a %.

xcopy /d /y %a% %b%
link|improve this answer
The result in cmd is "xcopy /d /y"!!!! – rima Nov 4 '10 at 8:38
@rima: because ignacio left out the "obvious" 2 set commands ... – akira Nov 4 '10 at 8:58
feedback

Your Answer

 
or
required, but never shown

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