Will this batch file work?

Products and tips

Moderator: Site Mods

Post Reply
User avatar
pschroeter
Silver Member
Silver Member
Posts: 283
Joined: 2007 Jan 27, 00:46

Will this batch file work?

Post by pschroeter »

@echo off
start /WAIT C:\RunCommandShortcuts\stap.lnk
shutdown –s

Will the this batch file run the indicated program (SyncToy), WAIT for it to finish, then shut down the computer? The reason I haven’t just created the batch file and run it to test it is SyncToy takes a little time to run and I’m not sure that if it is interrupted by a shutdown, the files being backed up could get corrupted.

I’m using a shortcut to start SyncToy because it was the only way I could get it to run with the right arguments. If I paste the following from the Target box of the Shortcut behind “start /WAIT” the program won’t start.

"C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -r
User avatar
nikos
Site Admin
Site Admin
Posts: 15806
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

try it and see! :)
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Post by FrizzleFry »

When you put quotes around the command start thinks that is the window title... so try

@echo off
start "SyncToy" /WAIT "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -r
pause
echo shutdown –s

You could add a pause or echo the shutdown command to check if the SyncToy command does finish... I have noticed that start /wait will not work if the command you run spawns other processes and ends.
User avatar
pschroeter
Silver Member
Silver Member
Posts: 283
Joined: 2007 Jan 27, 00:46

I figured out this code which works

Post by pschroeter »

I just want to mention that after asking someone I figured out this code which works:

Start "" /Wait "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -r
shutdown -s

I cannot figure out any rhyme or reason as to where the quote symbols go. I see quotes around /Wait and have no idea whats going on, I only know it works.
Post Reply