bat脚本显示本机IP地址的两种方法(内网ip)
有时候我们需要查看本机的ip地址,一般情况下都是到网上邻居或ipconfig命令查看,这里为大家分享下用bat实现的代码,喜欢的朋友可以试试
实现代码一: 通过 route print 实现
1 2 3 4 5 | @ 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% |
实现代码二:
1 2 3 | @ echo off for /f "tokens=15" %%i in ( 'ipconfig ^| find /i "ip address"' ) do ( echo %%i) pause>nul |