Making a batch file to run robocopy

Posted on 2007-10-04
Last Modified: 2011-01-28
Wrote a batch file called robocopy.bat
it contains the following:

robocopy d:\Users \\mggbkup\backup\BACKUP2007\users\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\users.txt
robocopy D:\shared \\mggbkup\BACKUP2007\shared\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\shared.txt
robocopy D:\profiles \\mggbkup\backup\BACKUP2007\profiles\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\profiles.txt
robocopy D:\IHVDI_Warehouse1 \\mggbkup\backup\BACKUP2007\IHVDI_Warehouse1\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\ihvdi.txt
robocopy \\ng1\NextGenRoot\DBBackup\ \\mggbkup\backup\BACKUP2007\dbbackup\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\dbbackup.txt
robocopy d:\mrep\ \\mggbkup\backup\BACKUP2007\mrep\ /S /E /COPYALL /NP /R:10 /W:30 /LOG:c:\mrep.txt

When I open a dos window and paste any of the lines one at a time (in separate dos windows), they run perfectly. When I try to run the batch file, the screen flickers like it can't run it and is in a loop. Am I missing something?  Running on my windows storage server. Any help would be greatly appreciated.

Question by:jaysimmons
    LVL 30

    Accepted Solution

    Don't name your batch file robocopy, name it runrobo.bat or something. The problem is that when you name it robocopy the robocopy commands in the batch file will call the batch file recursively.

    You could qualify the robocopy commands like, robocopy.exe, but it's just a bad idea to name the batch file the same name as a common exe.

    Author Comment

    That worked!  THANK YOU!!!!!!

    Expert Comment

    No not having the same problem. My batch file is named file copy.bat. And the batch itself runs fine when executed. Just isnt executing via scheduled task.

    Here is a copy of the script.
    REM This script will copy all the "new" files up to the network for heat treat
    C:\robocopy.exe  "C:\Documents and Settings\EGilbo\My Documents\New Folder" "S:\PUBLIC\HT_04_data\ht-04log" /E /R:0 /W:3 /XO /COPYALL /v /log:c:/robolog.txt

    Open in new window


    Expert Comment

    Wrong post. sorry.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
    Learn about cloud computing and its benefits for small business owners.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now