批处理获取本机IP地址
2019-9-17 乱云飞 标签: 批处理 获取IP 获取IP地址 本机IP
@echo off @for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (@set IP=%%a)>NUL 2>NUL @echo 本机IP地址是:%IP%
----------------------------
@echo off
@for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (set IP=%%a)
@echo 你的局域网IP是:%IP%
@pause>nul
@cmd/k
----------------------------
@echo off
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4"') do (set "ipAddress=%%a")
echo 本机IP地址是:%ipAddress%
cmd/k
评论:
mode con lines=6 cols=40
color 0A
title 查看本机IP地址
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (set IP=%%a)
echo.
echo.
echo 本机IP地址是:%IP%
cmd/k >nul