Solved

Can a batch script file run multiple commands at the same time?

Posted on 2007-04-05
5
26,210 Views
Last Modified: 2008-11-17
I've got a dos batch file that is scheduled to run every night to copy/backup files from different workstations at different branches to my server across different VPN links.

Right now, the batch file runs one line after the other.  Is there any way to have run multiple lines at the same time???  I want to copy files from multiple branches at the same time.  But I only want one item in the task scheduler.

Sample of current batch file

Robocopy \\branch1\sharename c:\backup\branch1 /e
Robocopy \\branch2\sharename c:\backup\branch2 /e
Robocopy \\branch3\sharename c:\backup\branch3 /e


Because the available download bandwidth at the main office is so much greater than the available upload bandwidth at the remote branches, I can run all three copies at the same time, and get the job done in 1/3 the time.

I know I could schedule each of the three, but with so many scheduled tasks in there already I would like to tell the batch file to run all three at the same time.

Is it possible?

Thanks!
0
Comment
Question by:brasslan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Accepted Solution

by:
Christopher McKay earned 100 total points
ID: 18859438
Use the start command before the robocopy command

start Robocopy \\branch1\sharename c:\backup\branch1 /e
start Robocopy \\branch2\sharename c:\backup\branch2 /e
start Robocopy \\branch3\sharename c:\backup\branch3 /e

This will launch the command and return to the batch file right away to continue running additional commands.

Hope this helps!

:o)

Bartender_1
0
 
LVL 17

Assisted Solution

by:RDAdams
RDAdams earned 85 total points
ID: 18859455
http://www.aumha.org/a/batches.php

Other good info options with the start command
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 65 total points
ID: 18859489
Agree that Bartender_1 has solved this one - I would just compact your script using:

For %%a in (branch1 branch2 branch3) do start Robocopy \\%%a\sharename c:\backup\%%a /e
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 18861468
Also agree bartender_1 has provided the solution, but to add, I consider it a best practice to get in the habbit of using quotes when using command line copying... helps prevent errors if and when you have a space in the specified path.  So to further expand on sirbounty's idea:

For %%a in (branch1 branch2 branch3) do start Robocopy "\\%%a\sharename" "c:\backup\%%a" /e
0
 
LVL 6

Author Comment

by:brasslan
ID: 18869539
I think I'm done getting comments on this one, so time to close it out.  I almost accepted a solution right after bartender's first response, but I'm glad I didn't.  The link that Adams gave me was awesome for including other batch commands and options!  Sir Bounty really had a good idea for compacting, now my batch file is much smaller, but more important, when I change the robocopy switches I only have to do it on 4 lines instead of on 40 lines!  Lee had a good idea, but to be honest, I already have the quotes because my source and destination already have spaces in them :-) (just couldn't see it in the sample!)

Thanks guys!
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

710 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