for /f "" %%A in ('hostname') do set HOSTNAME=%%A
for /f "tokens=2 delims=[]" %%A in ('ping %HOSTNAME% -4 -n 1 ^| find "Pinging"') do (
set IPADDR=%%A
)
You can also change whether you want an IPv4 address or IPv6 address by changing the -4 argument to -6.
No comments:
Post a Comment