[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Making a batch file to run robocopy

Posted on 2007-10-04
4
Medium Priority
?
18,484 Views
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.

Thanks!
Jay
0
Comment
Question by:jaysimmons
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
SteveGTR earned 1000 total points
ID: 20019542
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.
0
 

Author Comment

by:jaysimmons
ID: 20023116
That worked!  THANK YOU!!!!!!
Jay
0
 

Expert Comment

by:FastFord
ID: 27962405
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.

Erik
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

0
 

Expert Comment

by:FastFord
ID: 27962496
Wrong post. sorry.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

825 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