Description: |
call:getIP host ret |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.
|
:getIP host ret -- return THIS computers IP address
:: -- host [in,opt] - host name, default is THIS computer
:: -- ret [out,opt] - IP
:$created 20060101 :$changed 20080219 :$categories Network
:$source https://www.dostips.com
SETLOCAL
set host=%~1
set ip=
if "%host%"=="" ( for /f "tokens=2,* delims=:. " %%a in ('"ipconfig|find "IP Address""') do set ip=%%b
) ELSE ( for /f "tokens=2 delims=[]" %%a in ('"ping /a /n 1 %host%|find "Pinging" 2>NUL"') do set ip=%%a)
ENDLOCAL & IF "%~2" NEQ "" (SET %~2=%ip%) ELSE (echo.%ip%)
EXIT /b
|
|