Error in batch file to copy folder: 'Invalid number of parameters'

Solution 1:

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\"

Solution 2:

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.