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 am making a batch file in Windows XP to copy my folders I need to another folder on my PC. I am getting an error.

I get the error "Invalid number of parameters".

xcopy /s/z D:\Documents and Settings\%username%\Desktop C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Favorites C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Start Menu C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\My Documents C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\PrintHood C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\NetHood C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Templates C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Searches C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook C:\SomeRandomFolder\

Then I changed the batch and get this error: "File not found - Desktop"

xcopy /s/z D:\...\%username%\Desktop C:\SomeRandomFolder\

How do I fix these errors?

share|improve this question

You need quotes at least around the filenames or directories with spaces in them but the best is to quote the whole parameters to avoid other problems as suggested by Marcks Thomas in the comments:

xcopy /s/z "D:\Documents and Settings\%username%\Favorites" "C:\SomeRandomFolder\"

or in this particular case copying from a user home directory, as Phillip R. commented, to work on all windows versions (including other languages too) you can use:

xcopy /s/z "%userprofile%\<somefolder>" "C:\SomeRandomFolder\"
share|improve this answer
I suggest enclosing the entire path in quotes to avoid potential spaces in %username% being parsed as delimiters. – Marcks Thomas Dec 12 '12 at 16:44
good suggestion - thanks, will add it – laurent Dec 12 '12 at 16:46
Laurent - That worked. Thanks. – Daniel Dec 12 '12 at 17:28
Could use "%userprofile%\<somefolder>" instead of this portion. D:\Documents and Settings\%username% as well, which would work on all current versions of windows. – Phillip R. Dec 12 '12 at 19:36
@Phillip R. thanks for the suggestion, answer improved including it. – laurent Dec 14 '12 at 19:21

You need to put quotations around the directory path.

xcopy /s/z "D:\Documents and Settings\%username%\Desktop" "C:\SomeRandomFolder\"

It's giving you an error because there is a space in you directory path so it's seeing it as a new directory when it isn't and it can't find it.

share|improve this answer
This worked! Thanks – Daniel Dec 12 '12 at 17:29

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.