Jump to content

Recommended Posts

Posted

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 0

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.

Thanks for your response.

Steve.


Posted

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. :ph34r:

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.html

Choice.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.html

jaclaz

  • 4 months later...
Posted (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 loop

This 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 by Yzöwl
Code tags added...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...