# Choice Command



## MooseI386 (Dec 27, 2005)

I have been trying to consolidate several programs onto a USB Bootable hard drive. I have been using the Choice command in the Autoexec.bat file to give me a choice of what programs to start. However choice is only returning errorlevel 1; no matter what number I push. *Any ideals? Work in progress. *

Not I use a second choice to allow a 20 sec time so I may see what Echo measage is displayed. However no matter what I push I always Get
*Starting Re-image 1*

@ECHO OFF
:START
CLS
ECHO -------Enter Number-------------

ECHO 1- Image PC with XP image.
ECHO 2- Image PC with 2000 image.
ECHO 3- Load Ghost 2003.
ECHO 4- Load Techie's Toolkit.
ECHO 5- Load ERD Commander.
ECHO 6- Start Computer with CD-ROM Support.
ECHO 7- Start Computer without CD-ROM Support.
ECHO 8- Run GDISK to delete all partitions.
ECHO 9- Load Drive Scrubber for DOD Cleaning.

ECHO -------Enter Number-------------

ECHO OFF

CHOICE /N /C:123456789W /T:W,20 Select a number (Windows will start in 20sec)%1

IF ERRORLEVEL 1 GOTO XP
IF ERRORLEVEL 2 GOTO 2000
IF ERRORLEVEL 3 GOTO GHOST
IF ERRORLEVEL 4 GOTO TOOLKIT
IF ERRORLEVEL 5 GOTO ERD
IF ERRORLEVEL 6 GOTO CD 
IF ERRORLEVEL 7 GOTO NOCD 
IF ERRORLEVEL 8 GOTO GDISK 
IF ERRORLEVEL 9 GOTO DSCRUB
IF ERRORLEVEL w GOTO WIN

REM ------------1------------------------------ 
:XP 
ECHO Starting Re-image 1

CHOICE /N /C:Z,M /T:M,20 Will start over in 20 sec
IF ERRORLEVEL Z GOTO OVER
IF ERRORLEVEL M GOTO OVER2
:OVER
ECHO START OVER
GOTO START
:OVER2
ECHO START OVER
GOTO START

REM -------------2----------------------------- 
:2000 
ECHO Starting Re-image 2

CHOICE /N /C:Z,M /T:M,20 Will start over in 20 sec
IF ERRORLEVEL Z GOTO OVER
IF ERRORLEVEL M GOTO OVER2
:OVER
ECHO START OVER
GOTO START
:OVER2
ECHO START OVER
GOTO START

------------------------------------------------------------------------------------
AND SO ON AND SO ON

:END


----------



## Rockn (Jul 29, 2001)

You need to be loading command.com for the boot device to be able to initialize and use CHOICE. You also need all of the files like CHOICE, command.com, etc. on the boot device along with a path statement added to your autoexec.bat file pointing to the folder.


----------



## Dan Penny (Mar 25, 2005)

ERRORLEVEL parameters _
_
The first key you assign returns a value of 1, the second a value of 2, the _
third a value of 3, and so on. If the user presses a key that is not among _
the keys you assigned, CHOICE sounds a warning beep (that is, it sends a _
BEL, or 07h, character to the console). _
_
If CHOICE detects an error condition, it returns an ERRORLEVEL value of 255. _
If the user presses CTRL+BREAK or CTRL+C, CHOICE returns an ERRORLEVEL value _
of 0. _
_
When you use ERRORLEVEL parameters in a batch program, list them in _
decreasing order. 

Thus;

IF ERRORLEVEL w GOTO WIN
IF ERRORLEVEL 9 GOTO DSCRUB
IF ERRORLEVEL 8 GOTO GDISK 
IF ERRORLEVEL 7 GOTO NOCD 
IF ERRORLEVEL 6 GOTO CD 
IF ERRORLEVEL 5 GOTO ERD
IF ERRORLEVEL 4 GOTO TOOLKIT
IF ERRORLEVEL 3 GOTO GHOST
IF ERRORLEVEL 2 GOTO 2000
IF ERRORLEVEL 1 GOTO XP


----------

