| 1. |
Solve : Batch menu that works on every windows version?? |
|
Answer» Since the CHOICE command is not available on WINDOWS 2000 and XP, I used a construction like this:
Test on Win7: C:\>type menu.bat echo off :start ECHO. ECHO 1. print Hello ECHO 2. print Bye ECHO 3. print Test set choice= set /p choice=Type the number to print text. if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='1' goto hello if '%choice%'=='2' goto bye if '%choice%'=='3' goto test ECHO "%choice%" is not valid please try again ECHO. goto start :hello echo Hello goto start :test echo test goto start :bye echo bye C:\>menu.bat 1. print Hello 2. print Bye 3. print Test Type the number to print text.1 Hello 1. print Hello 2. print Bye 3. print Test Type the number to print text.3 test 1. print Hello 2. print Bye 3. print Test Type the number to print text. "" is not valid please try again 1. print Hello 2. print Bye 3. print Test Type the number to print text.2 byeI don't have access to Windows 7, so I couldn't test it. I also thought about running two ways with an OS check and using "choice" or "set /p". But I got confirmation meanwhile that it works on Windows 7. Thanks for your help. |
|