Results 1 to 11 of 11
  1. #1
    Lounger
    Join Date
    Dec 2009
    Location
    Pembroke Pines,Florida, USA
    Posts
    36
    Thanks
    0
    Thanked 1 Time in 1 Post

    Batch file won't run

    I have made a Batch file for running Robocopy from the instruction here:http://www.sevenforums.com/tutorials...up-script.html
    It's simple batch file, showing below (just 2 lines):
    robocopy B:\jkitc\Documents\Jarte G:\RobocopyBackups\Jarte /e /mir /np /log:backup_log.txt
    pause

    Here's the problem: I can copy that one line and paste it into a command prompt, and it runs fine. When I execute the Batch file, it will not run.
    It appears to be running, but it does not accomplish anything.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. The Following User Says Thank You to jkitc For This Useful Post:

    kaybee (2014-03-06)

  4. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    5,808
    Thanks
    185
    Thanked 701 Times in 639 Posts
    jkitc,

    Not sure why your command won't work in a batch file.
    I've used this batch file for years w/o problem DataBackup2V.cmd
    Code:
    Echo Off
    REM  Updated: 10/27/10
    Echo.  -------- Copying BEKDocs to V: drive -------
    Robocopy "G:\BEKDocs" "V:\BEKDocs" /MIR /XJD /R:5 /W:15 /MT:32 /V /NP /LOG:RoboCopy.log 
    Echo.  -------- Copy Completed              -------
    Note: this is executed from a shortcut on a toolbar.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  5. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    2,802
    Thanks
    18
    Thanked 106 Times in 100 Posts
    Two questions:
    1) is ROBOCOPY.EXE in the path? That is, is it being found?
    2) what is present in the backup_log.txt file?
    BATcher

    Mr Owl ate my metal worm

  6. #4
    Gold Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,376
    Thanks
    7
    Thanked 205 Times in 195 Posts
    Did you name the batch file "robocopy.bat"? Change the name if you did.

    cheers, Paul

  7. #5
    Lounger
    Join Date
    Dec 2009
    Location
    Pembroke Pines,Florida, USA
    Posts
    36
    Thanks
    0
    Thanked 1 Time in 1 Post
    RetiredGeek,
    I redid my batch file, and copied your format and it executed just fine. This is it below:

    Echo Off
    REM Made: 8/16/2012
    Echo. -------- Copying Files to G: drive --------
    robocopy "B:\jkitc\Documents\Jarte" "G:\RobocopyBackups\Jarte" /e /mir /np /log:B:\RoboCopy.txt
    Echo. ---------- Copy Completed ------------
    pause

    Thank you so much

    jkitc

  8. #6
    Lounger
    Join Date
    Dec 2009
    Location
    Pembroke Pines,Florida, USA
    Posts
    36
    Thanks
    0
    Thanked 1 Time in 1 Post
    BATcher,
    Please give me the steps.....to put it in the path.

    jkitc

  9. #7
    Gold Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,376
    Thanks
    7
    Thanked 205 Times in 195 Posts
    The easiest way is to copy Robocopy.exe to C\Windows\system32.

    In the batch file you should change the wait and retry options. Retry can be set to zero for a normal copy - /R:0. You would only need to retry if the file needed to be copied as soon as it was created and you have Robocopy running in monitor mode. The default retry value is 1 million.

    cheers, Paul

  10. #8
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    2,802
    Thanks
    18
    Thanked 106 Times in 100 Posts
    Yes, C:\Windows\system32 is a good place for Robocopy.exe.

    And an additional switch to use is /W:0 to set write retries to zero.
    /R:0 sets read retries to zero, as Paul T indicates.
    BATcher

    Mr Owl ate my metal worm

  11. #9
    Lounger
    Join Date
    Dec 2009
    Location
    Pembroke Pines,Florida, USA
    Posts
    36
    Thanks
    0
    Thanked 1 Time in 1 Post
    This is the contents of my re-worked Batch file:

    Echo Off
    REM Made: 8/16/2012
    REM Learned how to make this from: http://windowssecrets.com/forums/ - http://is.gd/H5RYho
    Echo. -------- Copying Files to G: drive --------
    robocopy "B:\jkitc\Documents\Jarte" "G:\RobocopyBackups\Jarte" /e /mir /np /R:0 /W:0 /log:B:\RoboCopy.txt
    robocopy "B:\Utilities" "G:\RobocopyBackups\Utilities" /e /mir /np /R:0 /W:0 /log+:B:\RoboCopy.txt
    robocopy "B:\Utilities_2" "G:\RobocopyBackups\Utilities_2" /e /mir /np /R:0 /W:0 /log+:B:\RoboCopy.txt
    robocopy "B:\PortableApps" "G:\RobocopyBackups\PortableApps" /e /mir /np /R:0 /W:0 /log+:B:\RoboCopy.txt
    robocopy "B:\Launcher" "G:\RobocopyBackups\Launcher" /e /mir /np /R:0 /W:0 /log+:B:\RoboCopy.txt
    Echo. ---------- Copy Completed --------
    pause

    I have a second hard drive that my data is stored on, and that is where I keep my batch file, but if I try to run it from there it will not run. I pin it to my START menu, and then it run great. Disk G:\ is my External hard drive where robocopy backs up my files.

    Thanks for all the help I get here.

  12. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    5,808
    Thanks
    185
    Thanked 701 Times in 639 Posts
    jkitc,

    You should have no problem running the command from any drive if RoboCopy is in C:\Windows\System32.
    Here's the target of my shortcut for the batch file I posted above.
    V:\BackupTasks\DataBackup2V.cmd
    Note: This shortcut is included in a Toolbar that resides on the Task Bar but I can also run it from the tool bar folder on my G: Drive.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  13. #11
    Gold Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,376
    Thanks
    7
    Thanked 205 Times in 195 Posts
    The /R & /W switches as listed in Robocopy.
    /R:n :: number of Retries on failed copies: default 1 million.
    /W:n :: Wait time between retries: default is 30 seconds.

    How do you run it from G:?
    Try opening a Command Prompt and type the name of the batch file including path. e.g. E:\Mycopy.bat

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •