标题: [网络连接] 怎么用批处理来获取主机上所有网卡的ip和mac吗 ? [打印本页]
作者: ben592 时间: 2024-9-21 15:30 标题: 怎么用批处理来获取主机上所有网卡的ip和mac吗 ?
- @echo off & setlocal enabledelayedexpansion
- echo =-----------------------------------------=
- echo = 本BAT只列出一个有线和一个无线的IP信息 =
- echo = 读取信息请耐心等待 =
- echo =-----------------------------------------=
- echo.
- for /f "tokens=1 delims=[]" %%i in ('%SystemRoot%\system32\nbtstat -S^|find /n "以太网:"') do (
- nbtstat -S | more +%%i >$
- set /p Str=<$
- del $
- for /f "tokens=2 delims=[]" %%i in ('echo "!Str!"') do set LIP=%%i
- )
- for /f "tokens=1 delims=[]" %%i in ('%SystemRoot%\system32\nbtstat -S^|find /n "WLAN:"') do (
- nbtstat -S | more +%%i >$
- set /p Str=<$
- del $
- for /f "tokens=2 delims=[]" %%i in ('echo "!Str!"') do set WIP=%%i
- )
- for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "IPv4 地址"') do set ip=%%i ?
-
- echo =================================================== >%tmp%\ip-mac.txt
- echo 当前时间:%DATE% >>%tmp%\ip-mac.txt
- echo =================================================== >>%tmp%\ip-mac.txt
- echo 本机用户名为:%COMPUTERNAME% >>%tmp%\ip-mac.txt
- echo 本机有线IP为:%LIP% >>%tmp%\ip-mac.txt
- echo 本机无线IP为:%WIP% >>%tmp%\ip-mac.txt
- ::echo 本机首选IP为:%ip% >>%tmp%\ip-mac.txt
- echo 本机物理地址: >>%tmp%\ip-mac.txt
- echo ===================================================
- for /f "tokens=1,3 delims=," %%i in ('getmac /v /nh /fo:csv ^| findstr
- "..-..-..-..-..-.."') do (
- echo %%i %%j >>%tmp%\ip-mac.txt
- )
- echo =================================================== >>%tmp%\ip-mac.txt
- ipconfig | findstr /i "以太网 无线 IPv4">>%tmp%\ip-mac.txt
- Start %tmp%\ip-mac.txt
复制代码
这个只能获取到当前的实体网卡ip,不能获取到外置网卡的ip,求教!
作者: Batcher 时间: 2024-9-21 15:48
回复 1# ben592
双击文件 C:\Windows\System32\cmd.exe
在打开的CMD窗口中依次执行以下命令:
ipconfig /all > 1.txt
回车
把生成的1.txt文件上传到网盘
说一下你需要获取的内容和格式
如果需要上传截图,可以找个图床,例如:
http://bbs.bathome.net/thread-60985-1-1.html
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |