Batch file & XCopy


  1. Posts : 3
    XP
       #1

    Batch file & XCopy


    I hope this is the correct forum??

    I have a small network with 2 XPs and 1 Win7. The Win 7 PC recently replaced on older XP PC. I have been backing up accounting data from one XP to another XP using a DOS batch file that uses the XCopy command and this has been working fine for several years. An accounting package that resides on the Win 7 PC can access the data on the XP with no problem.

    I moved the batch file to the Win7 PC and it fails with "Invalid drive specification".

    The data on the XP PC that needs to be copied resides in "c:\accounting\quickbooks" and "c:\accounting\peachtree". On the Win7 PC the "c:\accounting" is mapped as "Z".

    If I use the DOS prompt I can do a "Dir Z:\" and it works. I can also run the same xcopy command from the batch file at the DOS prompt and it works fine.

    The one xcopy command is:
    XCOPY Z:\QuickBooks\*.* c:\Data\Zipped\QuickBooks\ /E /V /C /H /R /Y

    Why does the batch file fail??? For some reason it can't "see" the "Z" drive. I also want to run the batch file nightly as a scheduled task.

    Thanks
      My Computer


  2. Posts : 1,800
    Windows 7 Pro x64 SP1
       #2

    Klingon said:
    I hope this is the correct forum??

    I moved the batch file to the Win7 PC and it fails with "Invalid drive specification".

    The data on the XP PC that needs to be copied resides in "c:\accounting\quickbooks" and "c:\accounting\peachtree". On the Win7 PC the "c:\accounting" is mapped as "Z".

    If I use the DOS prompt I can do a "Dir Z:\" and it works. I can also run the same xcopy command from the batch file at the DOS prompt and it works fine.

    The one xcopy command is:
    XCOPY Z:\QuickBooks\*.* c:\Data\Zipped\QuickBooks\ /E /V /C /H /R /Y

    Why does the batch file fail??? For some reason it can't "see" the "Z" drive. I also want to run the batch file nightly as a scheduled task.

    Thanks
    have you tried the batch files from the cmd prompt?

    can you type dir z:\quickbooks

    On some versions of quickbooks there is a space in the name, if so then you have to enclose the two parts of the xcopy in " marks.
    ie
    XCOPY "Z:\Quick Books\*.*" "c:\Data\Zipped\Quick Books\" /E /V /C /H /R /Y

    Rich
      My Computer


  3. Posts : 3
    XP
    Thread Starter
       #3

    (1) There are no spaces in the directory names.
    (2) I can run the batch file from the "C" prompt and it does copy files.
    (3) I can do dir z:\quickbooks from the "C" prompt.

    The way I run the batch file to test it is:
    (1) Open explorer
    (2) Right click on the batch file
    (3) Run as administrator
    (4) The batch file runs but I get the "invalid drive specification"

    If I change the XCOPY to copy from c:\... to c:\... on the Win7 PC the batch file runs OK. It just won't copy from a mapped networked drive to "C".
      My Computer


  4. Posts : 5,092
    Windows 7 32 bit
       #4

    Seems to be a common problem with nobody really nailing down the cause. This link seemed the most helpful:

    xcopy between networked computers? - Windows-XP-General-Discussion - Windows-XP

    The post with stuff about 'z' for computer name was the most interesting. I don't use xcopy enough to know the switches. An alternative may be RichCopy. If you google you can download free from MS. I'm not sure how good it is in batch files, but it copied my Windows.old, over 200,000 files, over a network without waiting a year to start the file copy. Didn't crap out either.
      My Computer


  5. Posts : 3
    XP
    Thread Starter
       #5

    I finally solved this! Mapping the directory as "Z" works fine on XP using XCopy in a bath file but does NOT work on Win7.

    For some reason, on Win 7, I have to use the UNC convention of the machine name of the XP I want to copy data from which is DJNTY391.

    The following works in XP but NOT Win7 where "Z:\Accounting" is a mapped network drive:
    xcopy Z:\QuickBooks\*.* c:\Data\..\QuickBooks\ /E /V /C /H /R /Y

    This works in Win 7:
    xcopy \\djnty391\accounting\quickbooks\*.* c:\data\..\quickbooks\ /e /v /h /r /y

    Applications can access the mapped drive but the batch file can not! Strange????
      My Computer


  6. Posts : 5,092
    Windows 7 32 bit
       #6

    Yeah, that was one of the suggestions in the threads I found, use the UNC name. But it doesn't always work. Looks like it's one of those quirks you can only fix by trial and error.

    I wish they would settle on some home networking conventions and leave them alone once they work. XP to Vista to W7 it's like it's changed every time and you have to fight new battles for little gain.
      My Computer


  7. Posts : 2,726
    Windows 7 Ultimate 64bit
       #7

    Maybe have a looky here Freeware Xcopy util
      My Computer


  8. Posts : 5,092
    Windows 7 32 bit
       #8

    The OP can run XCopy as it is, except from a batch file. There's some quirk in the way the command processor is interpreting mapped drives or command line params when embedded in batch. That's the issue.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:05.
Find Us