Computing.Net > Forums > Programming > Help with batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help with batch file

Reply to Message Icon

Name: amlife
Date: October 8, 2008 at 07:33:07 Pacific
OS: 2003
CPU/Ram: 2.4 GHz/2GB
Product: HP
Comment:

Hello all
I have been working on changing menu display
with on this batch file.

I found this open source batch file online.
The only thing I want to change is the
display of those menus.
as currently it get display as in the
attached picture.

http://xs132.xs.to/xs132/08413/batc...

I would like them to be in order

1. Home

2. School

3 Exit

and so on, as it will make it easy to
understand and use.

I tried to make so many changes to get it to
work the way I wanted
but no luck :(

Kindly requesting assistance.

Batch file
==========================================
@echo off
title Eric Burcham's IP Configuration Batch
File - 2005
setlocal
set OK=N

:again
set /p choice=Please enter 1[Home],
2[School] or END ??
if /i [%choice%]==[END] endlocal&goto
end
if [%choice%]==[] goto again
if [%choice%]==[1] goto 1
if [%choice%]==[2] goto 2
set /p xxx=wrong entry, press any key to
exit.
endlocal
goto end

:1
echo NIC setting for Home being
configured.....
@netsh exec home.txt
set /p see=IP changed successfully to
Home Settings [9]see new setting
[Enter]exit...
if [%see%]==[9] goto show
echo Ending IP Configuration
goto end

:2
echo NIC setting for School being
configured.....
@netsh exec school.txt
set /p see=IP changed successfully to
School Settings [9]see new setting
[Enter]exit...
if [%see%]==[9] goto show
echo Ending IP Configuration
goto end

:show
@netsh int ip show config

:end
@echo on
cls

==========================================




Sponsored Link
Ads by Google

Response Number 1
Name: pball
Date: October 8, 2008 at 08:13:16 Pacific
Reply:

This is an easy fix.

Replace the top section with this

:again
echo 1. Home
echo 2. School
echo 3. End
set /p choice=
if [%choice%]==[] goto again
if [%choice%]==[1] goto 1
if [%choice%]==[2] goto 2
if [%choice%]==[3] goto end
goto again

This will write each option to it's own line, and if 1, 2, or 3 isn't entered it will ask again.

Let me know how it works, haven't helped to many people here but this was simple.


0

Response Number 2
Name: amlife
Date: October 8, 2008 at 08:19:43 Pacific
Reply:

omg .. it did work :) Thanks a lot you saved
me lots of trouble.

I truly thank you, I took batch file crash course back in college and I watched batch files training videos .. but sometime there are those simple things will annoy you ..

anyways.. Thanks again :D


0

Response Number 3
Name: pball
Date: October 8, 2008 at 08:56:55 Pacific
Reply:

glad I could help.

This is one of those types of examples i keep a copy of and paste it in when I need to make a selection.

in fact I'll add this to my how to tutorial.


0

Response Number 4
Name: Mechanix2Go
Date: October 8, 2008 at 23:37:24 Pacific
Reply:

FWIW you can simplify your code:

[1] no need to endlocal before exit; it ends by itself

[2] same goes for echo on

[3] instead of multiple IF tests, try something like:

=========================================
@echo off
setLocal EnableDelayedExpansion

echo 1 do this
echo 2 do that
echo ENTER to quit

set /p c= pick one

if !c!'==' goto :eof
goto :!c!

:1
echo here's 1
goto :eof

:2
echo here's 2
goto :eof


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Help with batch file

Need help with batch file www.computing.net/answers/programming/need-help-with-batch-file/9707.html

Help with batch file (FOR /R) www.computing.net/answers/programming/help-with-batch-file-for-r-/14521.html

Help with Batch files www.computing.net/answers/programming/help-with-batch-files/12927.html