Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running multiple commands in cmd using batch file question...

Status
Not open for further replies.

dellphone

Technical User
Oct 29, 2017
87
US
Hi Guys,

I need some help on running multiple commands in cmd using batch file in Windows 10 Home and one computer using XP home.

What I would like to do is crate a batch file that will run multiple commands as I would like to do a nightly back up from all my computers on my home network to a backup computer and USB drive using the xcopy command. So each computer will do a back up various folders to the network computer and to the local USB drive and I will be putting this batch file in the Task Scheduler

I been playing around with this and cant get it completely to work right.

@echo off

xcopy /W /E /H /R /Y “C:\Users\B\Documents\Tools” “\\WIN10SERVER\Tools” & xcopy /W /E /H /R /Y “C:\Users\B\Desktop\1A2” “\\WIN10SERVER\1A2 Key”

exit

The issue I’m having is I get this message after it finished doing the first command “Press any key when ready to begin copying file(s)” and I do not want that as I want this process to be atomically with no need to press any key and g one to the second command.

So it looks like I must be just missing something to make this happen.

Thank you guys for the help.
 
Deniall,

Thank you so much, that did the trick!
 
You don't need to run everything on one line. It can be done on two separate lines, which will make it easier to debug if you don't know which one has gone wrong. I'd recommend looking at Robocopy - it is similar to xcopy but it recovers from network errors.

Code:
@echo off

xcopy /E /H /R /Y "C:\Users\B\Documents\Tools" "\\WIN10SERVER\Tools"
xcopy /E /H /R /Y "C:\Users\B\Desktop\1A2" "\\WIN10SERVER\1A2 Key"

exit
 
I nalso second Robocopy - but

>it is similar to xcopy but it recovers from network errors

should point out that these days xcopy supports the same /z option as Robocopy to recover from network errors
 
Another reason to use ROBOCOPY.[ ] A few years ago I had to convert my backup system from XCOPY to ROBOCOPY because (for reasons related more to my clients) the full path names of my "deeper" files began to exceed XCOPY's undocumented length limit.
 
>XCOPY's undocumented length limit.

Just to be pedantic, it is not XCOPY's undocumented length limit, it is a Win32 (documented) path limit (which then causes XCOPY to fail with a somewhat misleading error message)
 
Well, I like to use Robocopy because you can do the "scrolling across the screen" backup so that customers can see their backup running for a visual confirmation. It brings them into the backup process. Can Xcopy do that?

/TEE
 
Thanks everyone going to have to check out ROBOCOPY
 
SyncToy and Robocopy are not the same thing at all. Robocopy DID have a GUI version or add-on. Not sure if it's still current.
Link

Regardless, the GUI and the underlying robocopy.exe are totally separate from SyncToy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top