Help with a batch file


  1. Posts : 2
    Windows 8.1 Pro
       #1

    Help with a batch file


    I created a simple batch file to run XCOPY and copy all files and folders from a users directory to an external hard drive. The batch file works, but sometimes it will ask to copy all files Yes/No/All. The user has to select "a" in order for the batch file to continue.

    I want to set a task scheduler to execute the batch file, but if this prompt comes up and the user isn't in front of the computer when it executes, the batch file closes out after a certain amount of time and never copies the files and folders.

    My question, is there a switch to add to the batch file to choose All if asked? If so, what do i need to add to the batch file?

    This is the line i have in the batch file, XCOPY C:\Users\Username\* F:\backup /s /i
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hi Natssdad,

    natssdad said:
    ... but sometimes it will ask to copy all files Yes/No/All.
    XCopy is asking you whether or not it should overwrite destination files.

    natssdad said:
    Is there a switch to add to the batch file to choose All if asked?
    Yes, sort of. The /Y switch will tell XCopy to overwrite files in the destination; effectively supressing the 'Yes/No/All' prompt.

    Alternately, you could just stimulate an 'a' key to the command by piping the output from echo.
    Code:
    echo a | XCOPY C:\Users\Username\* F:\backup /s /I

    Nevertheless, you should be using ROBOCOPY for backup routines.

    Robocopy is far more flexible switch wise (over 80 unique switch options) and provides detailed information and statistics of its actions. Also, it is comparably faster than other methods of copying. Part of the secret in its speed lies in the fact that it ignores files for copying if it has not be modified (in the source location) since the last backup routine (also a switch is available to help further speed up the copying process by multithreading). This makes Robocopy a much more quicker choice over XCopy, especially for backing up large amounts of data.

    Code:
    ROBOCOPY "C:\Users\Username" "F:\backup" /s
    (Append the /MIR switch if you want Robocopy to instead mirror the complete directory tree of the source location)
      My Computer


  3. Posts : 1,049
    Windows 7 Pro 32
       #3

    Tutorial for ROBOCOPY here: ROBOCOPY - Create Backup Script
      My Computer


  4. Posts : 2
    Windows 8.1 Pro
    Thread Starter
       #4

    Thank you very much! That worked. I'll definitely check out ROBOCOPY

    Thanks again.
      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 08:53.
Find Us