Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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%
share|improve this answer
:X :X :X luv u. It work fine,Thanks... – rima Nov 4 '10 at 9:27

Batch variables begin and end with a %.

xcopy /d /y %a% %b%
share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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