|
Answer» hi all, i am need of some help for using the set command, in place of the choice command in XP. Here is my task: I need to create a menu in a box centered on the SCREEN from which users can choose from any of the following commands: net user, ipconfig, echo, findstr, XCOPY, set, and a way to exit. After making their selection, my batch file must display help for that command on a freshly blanked screen, stay there for the user to read, then redisplay the menu on a freshly blanked screen for the user to continue. Please help!!!! Your help would be greatly appreciated.
set /p a=- , /p is the option in set that allows it to be similar to choice.
@echo off cls & echo. & echo Choice echo A-Ipconfig & echo B-E^cho & echo C-Findstr & echo D-Xcopy & echo E-Set echo. & set /p chs=- & if "%chs%"=="a" set chsa=ipconfig if "%chs%"=="b" set chsa=echo & if "%chs%"=="c" set chsa=findstr if "%chs%"=="d" set chsa=xcopy & if "%chs%"=="e" set chsa=set cls & %chsa% /?Looks like diablo is very close, but forgot to test it. It needs a pause at the end. And even then only choices b & d work.(in XP anyway) Apparently the "if set ..." commands do not like to follow the & sign.
Try this: Code: [Select]@echo off cls & echo. & echo Choice echo A-Ipconfig & echo B-Echo & echo C-Findstr & echo D-Xcopy & echo E-Set echo. & set /p chs=- if "%chs%"=="a" set chsa=ipconfig if "%chs%"=="b" set chsa=echo if "%chs%"=="c" set chsa=findstr if "%chs%"=="d" set chsa=xcopy if "%chs%"=="e" set chsa=set cls & %chsa% /? pause>nul
For more information read this: MS-DOS set command help How to use the set command as a substitute for the choice command in Windows 2000 and Windows ... Quote from: rhoads on April 20, 2008, 08:32:15 PM hi all, i am need of some help for using the set command, in place of the choice command in XP. Here is my task: I need to create a menu in a box centered on the screen from which users can choose from any of the following commands: net user, ipconfig, echo, findstr, xcopy, set, and a way to exit. After making their selection, my batch file must display help for that command on a freshly blanked screen, stay there for the user to read, then redisplay the menu on a freshly blanked screen for the user to continue. Please help!!!! Your help would be greatly appreciated.
give this a try and let me know if you need it to do SOMETHING more.
code:
@echo off :loop
cls & echo. & echo Choice echo A-Ipconfig & echo B-Echo & echo C-Findstr & echo D-Xcopy & echo E-Set & echo F-EXIT
echo. & set /p chs=- echo %chs% |findstr /i /r "[a-f]" if /I %errorlevel% == 1 goto bad if "%chs%"=='' goto bad if not '%chs%'=='' SET Choice=%Choice:~0,1% if "%chs%"=="a" set chsa=ipconfig if "%chs%"=="b" set chsa=echo if "%chs%"=="c" set chsa=findstr if "%chs%"=="d" set chsa=xcopy if "%chs%"=="e" set chsa=set if "%chs%"=="f" goto exit
cls & %chsa% /? echo PRESS any key pause>nul goto loop
:bad ECHO "%chs%" is not valid. Please try again. ECHO. ping -n 2 localhost > nul GOTO Loop
:exitwow, thnx guys!!! i used set, if...........modified a bit using goto but cool!! Thnx again!!
|