I know this project look stupid, but it do help user who don't know the ipconfig. Here is my problem.
1. I have bug in my batch, since some command fail an don't go to the error page.
2. (I don't expect much in this one
) Since windows xp don't come with choice, I insert choice.com an choice.exe in the same folder but, I want to set choice.com as default to run in the same folder of the batch (for max compatibility) but if the batch encounter a 64 bit xp, vista (won't work with choice.com I think) it will run choice.exe
3. Feel free to improve my code
Maybe is going to be a open source batch
p.s. Sorry for my bad English! an feel free to use but lets me have some credit
:: turn echo off an change color
@echo off
color 1f
:: Main page
:start
cls
echo ----------------------------------------------------------------------
echo ____ __ ______ ____
echo /\ _`\ /\ \ /\__ _\ /\ _`\
echo \ \ \/\_\\ \ \___ __ _ __ __ __ \/_/\ \/ \ \ \L\ \
echo \ \ \/_/_\ \ _ `\ /'__`\ /\`'__\/'_ `\ /'__`\ \ \ \ \ \ ,__/
echo \ \ \L\ \\ \ \ \ \/\ \L\.\_\ \ \//\ \L\ \/\ __/ \_\ \__\ \ \/
echo \ \____/ \ \_\ \_\ \__/.\_\\ \_\\ \____ \ \____\ /\_____\\ \_\
echo \/___/ \/_/\/_/\/__/\/_/ \/_/ \/___L\ \/____/ \/_____/ \/_/
echo /\____/
echo \_/__/
echo.---------------------------------------------------- Make by: xcharge50
echo.
echo Main menu
echo =========
echo 1.Simple mode
echo 2.Pro mode (show all info)
echo 3.Winsock reset (Run as admin + use if option 1 or 2 don't work)
echo 4.Special thanks!
echo 5.Quit to command prompt
echo 6.Quit
echo.
echo (1, 2, 3, 4, 5 or 6)
choice /n /c:654321
if errorlevel 6 goto simple
if errorlevel 5 goto pro
if errorlevel 4 goto winsock
if errorlevel 3 goto thx
if errorlevel 2 goto procmd
if errorlevel 1 goto quit
:: Simple. Ask to run ip release (1 option)
:simple
cls
echo Do you want to run Ip Release (recomended)
echo.
echo you need to right click on you icon
echo an run as administrator
echo to run this function
echo.
echo (Y or N)
choice /n /c:yn
if errorlevel 2 goto cren
if errorlevel 1 goto release
:: Run ip release
:release
cls
echo Ip is gona be release in 5 sec
echo (If operation take more than 45 sec close the windows)
ping localhost -n 6 1>NUL 2>&1
echo.
ipconfig /release 1>NUL 2>&1
if errorlevel 1 goto norel
echo.
echo.----------
echo Ip Release
echo.----------
echo.
pause
:: Ask to run ip renew
:cren
cls
echo Do you want to run Ip Renew (The repair)
echo.
echo (Y or N)
choice /n /c:yn
if errorlevel 2 goto start
if errorlevel 1 goto renew
:: Run ip renew
:renew
cls
echo Ip is gona be renew in 5 sec
echo (If operation take more than 45 sec close the windows)
echo.
ping localhost -n 6 1>NUL 2>&1
ipconfig /renew 1>NUL 2>&1
if errorlevel 1 goto noren
echo.
echo.--------
echo Ip Renew
echo.--------
echo.
echo you ip is supposed to be ok
echo.
pause
goto start
:: If ip release fail ask
:norel
cls
echo ------------------------------
echo Ip release fail!
echo ------------------------------
echo Did you run as administrator?
echo The option release is optional
echo.
echo Do you want to run Ip Renew instead? (Y ot N)
echo or press R to retry Ip release
echo.
echo (Y, N or R)
choice /n /c:ryn
if errorlevel 3 goto start
if errorlevel 2 goto renew
if errorlevel 1 goto release
:: If ip renew fail ask
:noren
cls
echo ------------------------------
echo Ip renew fail!
echo ------------------------------
echo For some reason Ip renew fail!
echo (Cable unplug? No wireless signal? winsock corrupted?)
echo.
echo Do you want to try again? (Y or N)
echo.
echo (Y or N)
choice /n /c:yr
if errorlevel 2 goto start
if errorlevel 1 goto renew
:: Pro. Ask to run ip release (Option 2)
:pro
echo.
echo Do you want to run Ip Release
echo You may need to run as administrator
echo.
echo (Y or N)
choice /n /c:yn
if errorlevel 2 goto crenpro
if errorlevel 1 goto releasepro
:: Pr. Run ip release
:releasepro
echo.
@echo on
ipconfig /release
@echo off
if errorlevel 1 goto norelpro
pause
echo.
echo.----------
echo Ip Release
echo.----------
:: Pr. Run ip renew
:crenpro
echo.
echo Do you want to run Ip Renew
echo.
echo (Y or N)
choice /n /c:yn
if errorlevel 2 goto start
if errorlevel 1 goto renewpro
:: Pro. Run ip renew
:renewpro
echo.
@echo on
ipconfig /renew
@echo off
if errorlevel 1 goto norenpro
pause
echo.
echo.--------
echo Ip Renew
echo.--------
echo.
echo you ip is supposed to be ok
goto quitpro
:: Pro. If ip release fail ask
:norelpro
echo.
echo ------------------------------
echo Ip release fail!
echo ------------------------------
echo Did you run as administrator?
echo.
echo Do you want to run Ip Renew instead?
echo or press R to retry Ip release
echo.
echo (Y, N or R)
choice /n /c:ryn
if errorlevel 3 goto start
if errorlevel 2 goto renewpro
if errorlevel 1 goto releasepro
:: Pro. If ip renew fail ask
:norenpro
echo.
echo ------------------------------
echo Ip renew fail!
echo ------------------------------
echo For some reason Ip renew fail!
echo (Maybe) a winsock repair can solve this problem
echo.
echo Do you want to try again?
echo or press R to restart the program
echo.
echo (Y, N or R)
choice /n /c:ryn
if errorlevel 3 goto quitpro
if errorlevel 2 goto renewpro
if errorlevel 1 goto start
:: Winsock reset
:winsock
cls
echo windsock is going to be reset!
pause
@echo on
netsh winsock reset
@echo off
if errorlevel 1 goto winfail
echo windsock reset!
pause
goto start
:: If winsock reset fail
:winfail
echo.
echo ------------------------------
echo Winsock fail!
echo ------------------------------
echo For some reason Winsock fail!
echo did you run in admin?
echo if you did = bad news!
echo.
echo Do you want to try again?
echo (Y or N)
echo.
choice /n /c:ny
if errorlevel 2 goto winsock
if errorlevel 1 goto start
:: Special thanks
:thx
cls
echo ================
echo Special thanks!
echo ================
echo.
echo http://www.computerhope.com
echo.
echo an to the following member:
echo.
echo Sidewinder
echo BatchFileCommand
echo.
echo press any key to go back to main menu
pause 1>NUL 2>&1
goto start
:: Pro. ask Exit
:quitpro
echo Do you want to (G)o to command prompt or (C)lose all?
echo or press M to go back in main menu
echo.
echo (G, C, or M)
echo.
choice /n /c:mcg
if errorlevel 3 goto procmd
if errorlevel 2 goto quit
if errorlevel 1 goto start
:: Exit pro
:procmd
echo.
ipconfig /?
echo ------------------------
echo type exit to quit cmd
echo or ChargeIp to go back
echo ------------------------
cmd
:: exit program (3 option)
:quit
exit