none
xcopy - Invalid Drive Specification RRS feed

  • Question

  • I am trying to use xcopy to copy a file from a server (mainly server 2003) to a local location (currently xp, but later server 2003). But I keep getting "Invalid Drive Specification".

    I am typing:

    xcopy "\\123.123.123.123\e\folder\test.csv" "c:\reports\folder\csvfiles"

    the file 'test.csv' is created by another process on the remote server (in e:\folder), and I am needing to move it to the local server (c:\reports\folder) for further processing.

    I have tried all manner of combinations, but I still keep getting this message.

    What am I doing wrong???

    Thursday, March 3, 2011 11:48 AM

Answers

All replies

  • Hi,

    I see in your script: \\123.123.123.123\e\folder\test.csv
    Probably you dont have share disk e, then you must use admin share e$.

    xcopy "\\123.123.123.123\e$\folder\test.csv" "c:\reports\folder\csvfiles"

     

    Thursday, March 3, 2011 12:05 PM
  • cheers, I have just tried that, but alas it still gives the same error message. I have confirmed the files and folders named all exist where I say they should, even copying and pasting to make sure I get the capitalisation right.
    Thursday, March 3, 2011 1:20 PM
  • Make a simple test to check you have access to this path.

    dir  \\123.123.123.123\e$\folder\test.csv
    dir c:\reports\folder\csvfiles

    • Marked as answer by iGGt Thursday, March 3, 2011 2:34 PM
    Thursday, March 3, 2011 1:55 PM
  • Of course. I was testing on my local PC, which of course doesn't have full admin rights. When I tried it between two servers it was fine.

     

    (just out of interest, is there a way I can specify a username/password to use with xcopy?)

     

    cheers
    Thursday, March 3, 2011 2:34 PM
  • I believe that's what the RUNAS.EXE utility is for, see RUNAS/? at a command prompt.

    Tom Lavedas
    Thursday, March 3, 2011 2:45 PM
    Moderator
  • Or try map drive:

    net use x: \\123.123.123.123\e$\folder\  /user:<user> <password>
    xcopy x:\test.csv "c:\reports\folder\csvfiles"

    Thursday, March 3, 2011 5:52 PM
  • Listen to MichalGajda if you want close to 100% success.  Just remember to::net use /delete /Yes:: afterwards.. (that /Yes switch is an undocumented secret and can also be used with the initial net use)  Using URN's like that will land you with a bunch of failures if you are using this on a wide range of computer systems...

    Thursday, March 3, 2011 10:20 PM
  • Thats great, cheers guys. One last thing (hopefully), can I delete the file after copying it?
    Friday, March 4, 2011 9:41 AM
  • If I understand correctly.

    When you have right to do this and when you dont need this file then yes, you may delete it. Or just move this file.

    Friday, March 4, 2011 10:39 AM
  • Thanks, dude I had been looking for the solution over the internet before getting your solution. It worked like a charm!

    One correction though:- <user><password> need not be in angular braces, mine is working when I removed <> from both.

    Monday, March 4, 2019 11:09 AM