[英]Batch Script to get a IPV4 address of a computer then if the IP is within a range run a batch file
[英]how to get ipv4 address of particular adapter via batch script in windows 10
我正在嘗試獲取特定適配器的ipv4地址(例如,以太網適配器本地連接* 14),是否有任何命令或腳本在Windows 10中執行此操作。 如果有人已經過去做過感謝共享。
輸入-適配器名稱
輸出-僅適配器的IP地址
使用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
您可以嘗試使用此批處理腳本來獲得:
專用局域網IP(ipv4)
外部公共IP
MAC地址
@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%"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.