Batch file 获取网络接口名称并将All设置为DHCP批处理脚本

Batch file 获取网络接口名称并将All设置为DHCP批处理脚本,batch-file,dhcp,netsh,Batch File,Dhcp,Netsh,我正在尝试创建一个批处理,该批处理将获取所有网络接口名称(例如“局域网连接”、“局域网连接2”),并将它们设置为DHCP 这就是我到目前为止所拥有的: set netsh=wmic nic where "netconnectionid like '%%'" get netconnectionid for %%i in ("%netsh% | FIND /V 'Net'") do (netsh interface ip set address "%%i" dhcp) 我的输出是: set ne

我正在尝试创建一个批处理,该批处理将获取所有网络接口名称(例如“局域网连接”、“局域网连接2”),并将它们设置为DHCP

这就是我到目前为止所拥有的

set netsh=wmic nic where "netconnectionid like '%%'" get netconnectionid

for %%i in ("%netsh% | FIND /V 'Net'") do (netsh interface ip set address "%%i" dhcp)
我的输出是

set netsh=wmic nic where "netconnectionid like '%%'" get netconnectionid

for %%i in ("%netsh% | FIND /V 'Net'") do (netsh interface ip set address "%%i" dhcp)
文件名、目录名或卷标语法不正确


有人能帮我修改这个脚本,或者提出一个更好的方法吗?

这能满足你的需要吗

WMIC NICConfig,其中“IPEnabled='True'和DHCPEnabled='False'”调用EnableDHCP
请选择Stack Overflow(SO),通过单击答案左侧的灰色复选标记符号来接受有用的答案,学习如何在SO上表示感谢。另请参见,没有被接受答案的问题被评为未回答问题,即使有好的答案。