Advertisement

Is there a DOS command that does this?

Started by June 17, 2001 05:06 AM
5 comments, last by AndyMan 23 years, 7 months ago
Is there a DOS command that writes a list of options, so the user chooses one and one of a number of command lines executes? A .bat file with this would be easier than a readme telling you which command line to use and use less space than a simple .exe.
This should do what you need:

ECHO 1. MS-DOS Editor.
ECHO 2. MS-Windows. (default)
ECHO 3. Defrag the hard-drive.
ECHO 4. Quit.
CHOICE /C:1234 /N /T:2,5 Please choose a menu option.
IF ERRORLEVEL == 4 GOTO QUIT_MENU
IF ERRORLEVEL == 3 GOTO DEFRAG_HD
IF ERRORLEVEL == 2 GOTO RUN_WIN
IF ERRORLEVEL == 1 GOTO RUN_EDIT
:RUN_EDIT
CALL EDIT
:RUN_WIN
CALL WIN
:DEFRAG_HD
DEFRAG c:
:QUIT_MENU
ECHO Safe to switch off machine now...

Tell me if you still don''t understand how it works

-Zredna
Advertisement
ohhhhhhhhh ohhhhhwwwww good old days dos stuff
choice and errorlevel combination!


Arkon
[QSoft Systems]
Zredna''s example is missing a few things... here''s a fixed version.

@ECHO off
:SHOW_MENU
ECHO 1. MS-DOS Editor.
ECHO 2. MS-Windows. (default)
ECHO 3. Defrag the hard-drive.
ECHO 4. Quit.
CHOICE /C:1234 /N /T:2,5 Please choose a menu option.
IF ERRORLEVEL == 4 GOTO QUIT_MENU
IF ERRORLEVEL == 3 GOTO DEFRAG_HD
IF ERRORLEVEL == 2 GOTO RUN_WIN
IF ERRORLEVEL == 1 GOTO RUN_EDIT
:RUN_EDIT
EDIT
GOTO SHOW_MENU
:RUN_WIN
WIN
GOTO SHOW_MENU
:DEFRAG_HD
DEFRAG c:
GOTO SHOW_MENU
:QUIT_MENU
Damn, well anyway it wasn''t my own example I found it at an batch-programming site.

Zredna
BTW, there is no "CHOICE" command in Windows 2000, as far as I can tell. I know some batch files have done interesting kludges like create files called 1.BAT, 2.BAT, 3.BAT, 4.BAT etc. The contents of these batch files execute the various menu commands. The main batch file simply displays the menu and exists.

"All you need to do to learn circular logic is learn circular logic"
"All you need to do to learn circular logic is learn circular logic"
Advertisement
Thanks all
I tried it in Win98 and it worked. But for Win2k I spose I''ll have to use the kludgy method.

This topic is closed to new replies.

Advertisement