求批处理自动识别活动网卡并设置IP

2025-03-14 22:32:41
推荐回答(1个)
回答1:

@echo off
set /a name=192.168.1.168
netsh interface ipv4 set address "本地连接" static  192.168.0.%name% 255.255.255.0 192.168.0.1
netsh interface ip  set  address "本地连接" static  192.168.0.%name% 255.255.255.0 192.168.0.1
netsh  interface ipv4  set  dns "本地连接" static 8.8.8.8
netsh  interface ip  set  dns "本地连接" static 8.8.8.8
echo 设置完成
pause