Shutdown Batch file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lil rahmer
    New Member
    • Mar 2008
    • 2

    Shutdown Batch file?

    @echo off
    C:
    set choice=
    set /p choice=Do you wish to continue?
    If %choice%==no GOTO SHUTDOWN
    If %choice%==yes GOTO next
    :next
    echo It didn't work
    exit
    :SHUTDOWN
    set choice=
    set /p choice=Your computer is about to shutdown.Do you wish to continue?
    If %choice%==no shutdown -a
    If %choice%==yes shutdown -s -t:90
    pause
    exit


    That is my first batch file. Ive been having some problems with it looping. It will ask eache question over and over and over again. If someone could tell me how to fix it that would be great. I use windows xp. Thanks

    (p.s. if anyone has some good sites that tell how to create batch files please post)
  • MindBender77
    New Member
    • Jul 2007
    • 233

    #2
    Try this and note that your choice of Y or N is case sensitive.
    Code:
    @echo off
    CLS
    :start
    cls
    set choice1=
    set /p choice1=Do you wish to continue? (Y or N)
    IF NOT '%choice1%'=='' set choice1=%choice1:~0,1%
    If '%choice1%'=='N' goto end
    If '%choice1%'=='Y' goto Next
    cls
    ECHO "%choice1%" is not valid please try again
    ECHO.
    pause
    goto start
    :Next
    cls
    set choice2=
    set /p choice2=Your computer is about to shutdown.Do you wish to continue? (Y or N)
    IF NOT '%choice2%'=='' set choice2=%choice2:~0,1%
    If '%choice2%'=='N' shutdown -a
    If '%choice2%'=='Y' shutdown -s -t:90
    cls
    ECHO "%choice2%" is not valid please try again
    pause
    goto Next
    ECHO.
    :end
    exit
    A good source of batch file info is www.computerhop e.com/batch.htm
    Bender
    Last edited by MindBender77; Mar 11 '08, 08:05 PM. Reason: Code Correction

    Comment

    Working...