|
Answer» Hi All,
I am trying to write a bat file fin windows 2003. I want to use some special character as Options. But it is not taking as options.
When I am trying to give CHOICE /C KHNUXDSAQ?# /M "Choose an Option"
It gives me following ERROR ERROR: Invalid choice. The valid choice characters are: a-z, A-Z, 0-9 and ASCII values of 128 to 254.
Please suggest me how to INCLUDE the characters ? and # in choice command options?
Regards, NilashreeJust another option for you, I stopped using the choice command long AGO, I create menu options. If you wanted the menu to return when finished running sub just add goto menu at the end of the sub.
echo off setlocal Title Exchange Tools Menu set running=c:\menu GOTO MENU
:menu CLS echo Please make a selection echo. echo 1. Reboot Server echo 2. Start Stopped Services echo 3. Check Status of Exchange Services Echo 4. Start all services echo 5. Stop all services echo 6. Instructions echo. echo 7. Exit echo. set /P menu1= if "%menu1%" == "1" goto restart if "%menu1%" == "2" goto startstop if "%menu1%" == "3" goto check if "%menu1%" == "4" goto startall if "%menu1%" == "5" goto stopall if "%menu1%" == "6" goto document if "%menu1%" == "7" goto endApparently the Win2003 version of CHOICE is more RESTRICTIVE than the Win9x version. You may be SOL on this request: # (acsii 35) and ? (acsii 65) are not in the allowable range of keys.
Could I interest you in a square root (ascii 251) or degree symbol (ascii 248 )?
I'm suprised Microsoft resurrected CHOICE in Win2003. I wonder what Vista has planned.
The set /p command has it's uses, but unfortunately it doesn't restrict reponses to a single character without some quirky coding.
If the user doesn't select a specified option do this. Place the code below after "if "%menu1%" == "7" goto end" statment
cls Echo Sorry you selected an invalid option, Hit enter to try again or press 7 to exit. set /p error= IF "%error%" == "7" ( goto end ) ELSE ( goto menu )
I hope this helps
|