:: Autor ne0x
:: Sintaxis
:: call:dg variable
:: variable Nombre de la variable en la que se almacenara la IP de la puerta de enlace
:dg
ipconfig | find "Puerta de enlace . . . . . 1" > %TMP%\rd.tmp
for /F %%A "tokens=11" IN (%TMP%\rd.tmp) DO set %2=%%A
goto:EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDG dg
::
:: By: Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains the default gateway. For NT4/2000/XP/2003.
:: If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive default gateway (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "g=0.0.0.0" & set "j="
for /f "tokens=3" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
if not defined j for %%b in (%%a) do set "g=%%b" & set "j=1")
endlocal & set "%1=%g%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::