Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 trying to use xcopy on a remote machine with psexec but i keep getting an error 4 and would love some brainstorming as to why that error might come up. The actual error says: Invalid drive specification 0 File(s) xcopy exited on 'remote machine' with error code 4

The command I am using is: psexec \'remote machine' -u 'user' -p 'pass' xcopy 'source path of file' 'destination path'

Both file paths are located on the remote machine. I am typing the command on my local machine. Any advice or questions are very welcome. Thanks!

share|improve this question
If you try the command locally on the target machine using the same credentials to log on does it work? – Helvick Nov 13 '10 at 7:13
Have you tried using UNCs (maybe using the admin shares c$,d$) instead of local paths? – Zoredache Nov 13 '10 at 8:35
Are you copying files locally on the remote machine? i.e.: copying from one local directory/drive to another? – Simon Catlin Nov 13 '10 at 17:24
Just to clarify some of your questions, it does work locally when the destination path is on my machine. The source path is a shared network drive and the destination path is a path located on the remote machine. – Ben Nov 15 '10 at 22:11
up vote 1 down vote accepted

It seems that error 4 means: "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."

EDIT: Microsoft's page on XCOPY

share|improve this answer
There is definitely enough space for the file and copy activity. I think that error is coming up because I am leaving something out maybe. – Ben Nov 15 '10 at 22:12
Replace xcopy with a batch file that echoes its arguments. Is what is printed what you expect it to be? – adamo Nov 17 '10 at 12:48

So I fixed this after changing a few things. I made sure the parameters in the exact order as the psexec documentation and I added the domain in front of the username. I'm not sure exactly what fixed it, but it works now. Thanks for all the pointers, they taught me a lot.

share|improve this answer
You have to close the question, because it resurfaces on the top page, although you fixed the problem. – adamo Nov 26 '10 at 21:37
sorry, how do I do that? – Ben Dec 1 '10 at 19:23

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.