Batch Menu - Not Working...what am I missing?

November 1, 2010 at 15:14:49
Specs: Windows XP
What the heck am I missing. These options always take me into :RENAME section. It looks like the menu may not be working as intended (obviously) but what am I missing with the goto statements?

++++++++++++++++++++++++START OF BATCH+++++++++++++++++++++++++++++
@echo off
cls

:MENU

echo 1.) The interface needs to be renamed to "LAN"
echo 2.) The interface is already named "LAN"
echo 3.) Save and Dump NIC Settings
echo 4.) Import NIC Settings
echo 5.) Take me out of this loop!


set /p userinp=Choose a number(1-5):
if '%unserinp%'=='1' goto RENAME
if '%unserinp%'=='2' goto DUMP
if '%unserinp%'=='3' goto DUMP
if '%unserinp%'=='4' goto IMPORT
if '%unserinp%'=='5' goto END


:RENAME
netsh interface set interface name="Local Area Connection" newname="LAN"
echo The Interface should have been renamed. Kindly double check the work.
echo Thank You
pause

goto MENU

:DUMP
netsh interface dump > c:\int.dmp
echo The interface configuration has been dumped to C:\
echo Kindly double check the work
echo Thank You
pause

goto MENU

:IMPORT
netsh exec c:\int.dmp
echo The Interface configuration has been imported
echo Kindly double check the work
Echo Thank You
pause

goto MENU

:END
pause
quit
+++++++++++++++++++++++++++END OF BATCH+++++++++++++++++++++++++++++


See More: Batch Menu - Not Working...what am I missing?

Report •


#1
November 1, 2010 at 15:18:49
Use double quotes:

if "%unserinp%"=="1" goto RENAME
ECT...

Good Luck.

Can I put a question here?


Report •

#2
November 1, 2010 at 15:21:26
I just replaced all the single quotes with double quotes, it still appears to be ignoring the goto commands, no matter what I do it only takes me through the :RENAME section

Report •

#3
November 1, 2010 at 15:29:29
Ahh, found it. Time for a spell check.

set /p userinp=Choose a number(1-5):
if '%unserinp%'=='1' goto RENAME

Can I put a question here?


Report •

Related Solutions

#4
November 1, 2010 at 15:32:21
Ahhhhh, of course. geeze.....my bad.

Thank you for your time!


Report •

#5
November 1, 2010 at 15:33:01
set /p userinp=Choose a number(1-5):
goto :%userinp%
:1
:2
...
:5



=====================================
Life is too important to be taken seriously.

M2


Report •

#6
November 1, 2010 at 15:36:44
M2, The only problem with that is that if somebody entered say 7, it would crash. If this is only used by the OP and a few others, maybe that isn't a problem however.

Can I put a question here?


Report •

#7
November 2, 2010 at 00:11:01
@echo off & setLocal EnableDELAYedeXpansion

set /p C=1 or 2 ?
goto :!C! 2>nul
:1
echo.one & goto :eof
:2
echo.two


=====================================
Life is too important to be taken seriously.

M2


Report •

#8
November 2, 2010 at 02:06:56
It still does crash if someone does input a wrong choice, example 3.

This should do it;

@echo off
:MAIN
cls
set /p C= Choose 1 or 2 :
if %C%==1 goto 1
if %C%==2 goto 2
if not "%C%" equ " a" goto ERROR

:1
echo ONE & pause & goto EXIT

:2
echo TWO & pause & goto EXIT

:ERROR
echo Invalid input, please try again. & pause & goto MAIN

:EXIT
exit

Happy is ONE who says I am an OttoMAN.


Report •

#9
November 2, 2010 at 02:30:23
You can't idiot-proof everything.

You could use CHOICE.EXE which sits there until an allowed key is pressed.


=====================================
Life is too important to be taken seriously.

M2


Report •


Ask Question