stevielamb Posted October 26, 2013 Share Posted October 26, 2013 I had actually forgotten that the "for loop" existed in windows batch scripts! Anyway, here's a revised version of the script:-@echo offsetlocal enableDelayedExpansionFOR /l %%s in (10, -1, 0) DO ( cls choice /C YNX /n /t 1 /d X /M "Invoking SyncToy in %%s seconds, press Y to cancel or N to proceed anyway." if !errorlevel!==1 ( echo Sync cancelled. Logging off... exit /B ) if !errorlevel!==2 goto backup):backupecho Invoking SyncToy...CALL "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -Rexit /B 0In reply to your other question, the "Sync cancelled. Logging off..." message remains on the screen just long enough to read it before the dos window shuts.Thanks for your response.Steve. Link to comment Share on other sites More sharing options...
jaclaz Posted October 26, 2013 Share Posted October 26, 2013 In reply to your other question, the "Sync cancelled. Logging off..." message remains on the screen just long enough to read it before the dos window shuts.Hmmm, you must be a speed reader or have a slowish machine. Seriously , inserting some kind of loop/delay between the echo and the exit command may be not a totally absurd idea.For the record:http://ss64.com/nt/choice.htmlChoice.exe is a standard command in Windows 2003, Vista and Windows 7 (for XP you can use the early resource kit versions).so, anyone with XP (or earlier) may have issues with it's use.If an external something is needed/wanted, the choice.exe from FreeDOS should work on those:http://winsupport.org/utilities/freedos-choice.htmljaclaz Link to comment Share on other sites More sharing options...
AwesomeKing Posted March 18, 2014 Share Posted March 18, 2014 (edited) Here is a code i made that can countdown from any number.@echo off@title Freedom@color 0bset /a b=%a%-1echo CountDown Time?set /p a=:loopclsset /a a=%a%-1echo %a%ping -n 2 127.0.0.1>nulgoto loopThis one closes after it runs out@echo off@title Freedom@color 0bset /a b=%a%-1echo CountDown Time?set /p a=:loopclsset /a a=%a%-1echo %a%ping -n 2 127.0.0.1>nulif %a%==0 goto finishgoto loop:finishecho Complete. Now Exiting...pause>nulexit Edited March 19, 2014 by Yzöwl Code tags added... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now