windows - 如何通过 Windows 10 中的批处理脚本获取特定适配器的 ipv4 地址

标签 windows batch-file

我正在尝试获取特定适配器的 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

关于windows - 如何通过 Windows 10 中的批处理脚本获取特定适配器的 ipv4 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47278359/

相关文章:

Windows Shell 上下文菜单选项

python - 在 Python 中使用 os.rename() 重命名文件时出错

c# - 如何创建批处理文件来备份Mysql数据库?

windows - 如何从 `for` 处理的项目(在 `in` 之后)调用子程序?

python - 如何在 Windows 中的 Python 3 中制定端口转发规则?

windows - 如何使用 Windows 符号链接(symbolic link)正确地 git clone 指向子模块中的文件夹

python - 如何让窗口聚焦于 Windows 并调整它的大小?

batch-file - 从批处理文件为 exe 创建快捷方式

windows - 如何从 Windows 命令行运行 Maxima

windows - 任务列表未检测/支持超过 21 个字符的进程名称