View Single Post
  #1  
Old 09-27-2004, 02:10 AM
Muuss
Dragon
 
Join Date: May 2003
Posts: 539
Default Updated boot5zones

As I m bored at work, i modified my boot5zones.bat file to automatically detect my external ip address. It changes each time i connect my box to internet.

Don't write that code, COPY PASTE it or you may forget some backquotes
Code:
@echo off

REM >> Update INTERNAL_IP with the IP address used by YOUR server on YOUR lan
set INTERNAL_IP=192.168.0.2

if NOT exist spells_en.txt goto NOSPELL

for /f "tokens=1-7 usebackq delims=:. " %%a in (`ipconfig ^| find "IP" ^| find "ress" ^| find /v "0.0.0.0" ^| find /v "%INTERNAL_IP%"`) do set EXTERNAL_IP=%%d.%%e.%%f.%%g
echo External ip for this system is %EXTERNAL_IP%, internal is %INTERNAL_IP%

start zone . %EXTERNAL_IP% 7995 %INTERNAL_IP%
start zone . %EXTERNAL_IP% 7996 %INTERNAL_IP%
start zone . %EXTERNAL_IP% 7997 %INTERNAL_IP%
start zone . %EXTERNAL_IP% 7998 %INTERNAL_IP%
start zone . %EXTERNAL_IP% 7999 %INTERNAL_IP%

exit
cls 

:NOSPELL
echo Copy spells_en.txt into that directory !
Please be aware that the row starting by for may not perfectly work on localized windows. Adapt it to yours :

type ipconfig on your computer, search the row showing your external ip address, then, modify the 'find' commands to select only that row.

Once done, modify the tokens=1-7 option and the %%c...%%f variables to catch the 4 numbers of your ip address.

If you do this in command line, use the single % syntax, not the double % one, IE :

for /f "tokens=1-7 usebackq delims=:. " %a in (`ipconfig ^| find "IP" ^| find "ress" ^| find /v "0.0.0.0"`) do set EXTERNAL_IP=%d.%e.%f.%g

Could someone confirm if this is working on a US windows (french one here) ?

Muuss
__________________
Muuss - [PEQGC] Dobl, the ogre that counts for 2 !
http://www.vilvert.fr/page.php?id=10
Reply With Quote