Funcion GetIP

Iniciado por ANTRAX, Julio 18, 2011, 09:41:54 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Código: dos
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetIP ip
::
:: By:   Ritchie Lawrence, 2003-09-22. Version 1.0
::
:: Func: Obtains the IP address of primary adapter. For NT4/2000/XP/2003.
::       If functions fails, 0.0.0.0 is returned.
::
:: Args: %1 var to receive IP address (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS & set "i=0.0.0.0" & set "j="
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j for %%b in (%%a) do set "i=%%b" & set "j=1")
endlocal & set "%1=%i%" & goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::