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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file with START command ignores the /WAIT option

Status
Not open for further replies.
Oct 7, 2007
6,597
0
36
US
I have a batch file set to run as a scheduled task on Windows 7 and XP machines. It's supposed to copy the contents of three folders (actually mirror them) to a server folder one at a time. In essence, three separate copy jobs, one after the other.

This works in XP with the same batch file, but in W7, all three copy jobs start immediately. In XP, the first copy job completes and the second copy job starts in the same CMD window.

By the way, the CMD window is hidden in Windows 7 while it is running whereas it is visible in XP. Not sure if these are two separate issues or related. I would prefer the windows to be visible.


start /wait /b "Job 1" robocopy.exe C:\Users\jimmo\BobOutlook \\server1\shared\mailbackup\jimmo\Bob /MIR /ZB /R:2 /W:5 /LOG:"c:\backup1.log"
start /wait /b "Job 2" robocopy.exe C:\Users\jimmo\LarryOutlook \\server1\shared\mailbackup\jimmo\Larry /MIR /ZB /R:2 /W:5 /LOG:"c:\backup2.log"
start /wait /b "Job 3" robocopy.exe C:\Users\jimmo\AppData\Local\Microsoft\Outlook \\server1\shared\mailbackup\jimmo\jimmo /MIR /ZB /R:2 /W:5 /LOG:"c:\backup3.log"

 
Do you get the same behavior if you manually run the batch file, or does this only occur when running as a scheduled task?

Joey
CCNA, MCSA 2003, MCP, A+, Network+, CWTS
 
How about appending a "call" statement & run only the first batch file in startup. Then when it completes it "calls" the second one, which in turn "calls" the third, etc.

Original MUG/NAMU Charter Member
 
I did NOT try to run it manually after I got the script "perfected". I'll have to try that. I was running late so I was just happy that it was working. I had a big problem with robocopy objecting to the syntax of my log file parameter.

What about the CMD window being hidden???

MiteInMyBlood: Yes, I could do that, but it worked on XP and I would like to figure it out AND that solution is less "elegant". Yes, I'm a bit of a perfectionist.
 
Regarding the HIDDEN batch file window: Saw this posted on a Microsoft site, but don't know that it's gospel.

"I discovered that a task has to be set for "run only when user is logged in" to be visible. Otherwise it is hidden (regardless of the setting of the "Hidden" checkbox)."

But, I want it to be set for "Run whether user is logged on or not" since the job wouldn't run with the user logged out. I guess a HIDDEN, but successful task is better than a visible, always failing task.
 
Maybe I solved my own problem:

Because the definition of the START /B command is:
/B Start application without creating a new window.

AND there is NO Window as is hidden, it doesn't do the WAIT part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top