up vote 3 down vote favorite
share [g+] share [fb]

Under some circumstances, xcopy will return the error Invalid number of parameters without giving you a clue as to what’s going on. The usual solution for this is to be sure that your filenames are enclosed in quotes, as this can be an issue with batch files where you have something like xcopy %1 %2 and you really need xcopy "%1" "%2". I recently ran into a problem, however, where the problem wasn't spaces:

C:\Temp\foo>c:/windows/system32/xcopy.exe /f /r /i /d /y * ..\bar\
Invalid number of parameters
link|improve this question
feedback

migrated from stackoverflow.com Feb 27 '10 at 9:44

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

The solution to this one was tricky: it turns out that xcopy is parsing the forward slashes in the path to its own binary. This works fine:

C:\Temp\foo>c:\windows\system32\xcopy.exe /f /r /i /d /y * ..\bar\
C:\Temp\foo\blah -> C:\Temp\bar\blah
1 File(s) copied

You can also run into this if you have your PATH defined using forward slashes instead of backslashes.

link|improve this answer
1  
You answered 1 minute and 12 seconds after posting the question. Why did you ask the question in the first place? – Roger Pate Feb 26 '10 at 0:44
3  
To make the information available for anyone using Stack Overflow to search for a solution to this problem that had me wracking my brains for half an hour. – Slothman Feb 26 '10 at 0:49
Then why not ask the real underlying question, since this isn't particular to xcopy: stackoverflow.com/questions/2338820/… It just seems that what you have so far amounts to a "wow, that's interesting" blog post, and not a real question. – Roger Pate Feb 26 '10 at 0:52
1  
It was a problem that I had trouble solving. I wanted to put the solution out there for other people to save them time. The Stack Overflow FAQ says “It's also perfectly fine to ask and answer your own question, but pretend you're on Jeopardy: phrase it in the form of a question.” I don’t know of this problem occurring with other utilities than xcopy, so I didn’t feel it was appropriate to generalize. – Slothman Feb 26 '10 at 0:58
@Slothman: Maybe I'd not have seen your question as a "glorified blog post" if you had worded it differently and more programming-related (I don't understand the migrate-to-SU closers, and myself voted to close as too localized). In particular, the question is hiding the real issue (/ vs \) and is misleading in that way. – Roger Pate Feb 26 '10 at 1:44
show 2 more comments
feedback

May be you have space in file/folder name

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.