Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-04-05
5
Medium Priority
?
26,925 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 400 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 340 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 260 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
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…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

730 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