我正在尝试获取特定适配器的ipv4地址(例如以太网适配器本地连接* 14)在Windows10中是否有任何命令或脚本可以执行此操作。如果有人已经在过去做了感谢分享它。
输入--适配器名称
输出--仅适配器的ip地址
发布于 2017-11-14 14:36:00
使用netsh
在批处理文件中
@echo off
for /f "tokens=3 delims=: " %%I in ('netsh interface IPv4 show addresses "Ethernet adapter Local Area Connection" ^| findstr /C:"IP Address"') do echo %%I
如果从命令行使用,而不是批处理,请删除%%I
中的一组%
,如下所示。
for /f "tokens=3 delims=: " %I in ('netsh interface IPv4 show addresses "Ethernet adapter Local Area Connection" ^| findstr /C:"IP Address"') do echo %I
发布于 2017-11-14 16:33:52
您可以尝试使用此批处理脚本来获取:
@echo off
Title Get (LAN ,Public) (IP) and MAC Addresses by Hackoo 2017
mode con cols=80 lines=5 & Color 9E
echo( & echo(
echo Please Wait a While ... Searching for (LAN ,Public)(IP) and MAC addresses ...
Set "LogFile=%~dpn0.txt"
@for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do (
set "LAN_IP=%%a"
)
for /f "tokens=2 delims=: " %%A in (
'nslookup myip.opendns.com. resolver1.opendns.com 2^>NUL^|find "Address:"'
) Do set ExtIP=%%A
@For /f %%a in ('getmac /NH /FO Table') do (
@For /f %%b in ('echo %%a') do (
If /I NOT "%%b"=="N/A" (
Set "MY_MAC=%%b"
)
)
)
Cls
echo(
echo My Private LAN IP : %LAN_IP%
echo My External Public IP : %ExtIP%
echo MAC Addres : %MY_MAC%
(
echo My Private LAN IP : %LAN_IP%
echo My External Public IP : %ExtIP%
echo MAC Address : %MY_MAC%
)>"%LogFile%"
Timeout /T 5 /NoBreak>nul
Start "" "%LogFile%"
https://stackoverflow.com/questions/47278359
复制相似问题