faqts : Computers : Programming : Languages : Batch language : MSDOS

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

32 of 47 people (68%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I make a 'program launch menu' in dos for my favorite programs with a batch script?

Mar 21st, 2002 12:05
Jason Stracner, http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q77457&


Here is a cool batch script that you can use to make a menu of programs 
or files that you use all the time.  This script requires a tiny 
program named Answer.com.  
First you will need to create the answer.com program that will allow 
you to accept a single keystroke.  To do this all you have to do is 
type some text on the command line.  Here is the text out of a dos 
window where I made the program.  It uses a dos called debug.exe that 
is standard issue in windows and dos.
C:\batmenus>debug
-a
0B65:0100 XOR     AX,AX
0B65:0102 INT     16
0B65:0104 MOV     AH,4C
0B65:0106 INT     21
0B65:0108
-rcx
CX 0000
:8
-n answer.com
-w
Writing 00008 bytes
-q
Okay that is a little hard to read.  To make it a bit clearer I will 
put parenthesis around what I actually typed.
C:\batmenus>(debug)
-(a)
0B65:0100 (XOR     AX,AX)
0B65:0102 (INT     16)
0B65:0104 (MOV     AH,4C)
0B65:0106 (INT     21)
0B65:0108 (press enter)
-(rcx)
CX 0000
:(8)
-(n answer.com)
-(w)
Writing 00008 bytes
-(q)
Anyway.  Here is the batch script that uses the program that we just 
created above.  You should put this text in a file called something 
like my-menu.bat and just run that .bat file to use your menu.
@ECHO OFF
COLOR 0C
:TOP
C:
CD C:\BATMENUS\
CLS
ECHO ###################################################################
ECHO #                                                                 #
ECHO #                 Jason's super cool dos menu.                    #
ECHO #                                                                 #
ECHO ###################################################################
ECHO #                                                                 #
ECHO #   A. Python                                                     #
ECHO #   B. My VB menu                                                 #
ECHO #   C. Frontpage                                                  #
ECHO #   Z. Edit this menu.                                            #
ECHO #                                                                 #
ECHO ###################################################################
ECHO #                         (ESC) = Exit                            #
ECHO ###################################################################
:START
C:\BATMENUS\ANSWER.COM
REM Choice key.
REM  A  B   C   D   E   F   G   H   I   J   K   L   M   N
REM 65 66  67  68  69  70  71  72  73  74  75  76  77  78
REM  O   P   Q   R   S   T   U   V   W   X   Y   Z
REM 79  80  81  82  83  84  85  86  87  88  89  90
REM  a  b   c   d   e   f   g   h   i   j   k   l   m   n
REM 97 98  99 100 101 102 103 104 105 106 107 108 109 110 
REM  o   p   q   r   s   t   u   v   w   x   y   z
REM 111 112 113 114 115 116 117 118 119 120 121 122
IF ERRORLEVEL 122 IF NOT ERRORLEVEL 123 GOTO CHOICEZ
IF ERRORLEVEL 90 IF NOT ERRORLEVEL 91 GOTO CHOICEZ
IF ERRORLEVEL 99 IF NOT ERRORLEVEL 100 GOTO CHOICEC
IF ERRORLEVEL 67 IF NOT ERRORLEVEL 68 GOTO CHOICEC
IF ERRORLEVEL 98 IF NOT ERRORLEVEL 99 GOTO CHOICEB
IF ERRORLEVEL 66 IF NOT ERRORLEVEL 67 GOTO CHOICEB
REM Lower case a
IF ERRORLEVEL 97 IF NOT ERRORLEVEL 98 GOTO CHOICEA
REM Upper case A
IF ERRORLEVEL 65 IF NOT ERRORLEVEL 66 GOTO CHOICEA
REM The escape key.
IF ERRORLEVEL 27 IF NOT ERRORLEVEL 28 GOTO END
GOTO END
:CHOICEA
CLS
python
PAUSE
GOTO TOP
CLS
:CHOICEB
CLS
C:\batmenus\vb-menu.bat
GOTO END
CLS
:CHOICEC
CLS
start "C:\Program Files\Microsoft Office\Office10\FRONTPG.EXE"
GOTO END
:CHOICEZ
CLS
start C:\dosmenu\MEL C:\batmenus\my-menu.BAT
GOTO END
:END
echo the end
echo %ERRORLEVEL%
CLS
color