::命令前加@符号,表示不显示@后面的命令. @echo off title Open / Close Network ::本地网络适配器名称 set name=以太网 ::查看网络状态,后反向设定 netsh interface show interface "%name%" | findstr "已禁用" >nul 2>nul && ( set state=enabled set msg="网络已启用" ) ||
例子: 本地连接修改IP netsh interface ip delete dns "本地连接" addr=allnetsh interface ip add dns "本地连接" addr=202.101.172.35netsh interface ip add dns "本地连接" addr=202.101.172.36netsh interface ip add address "本地连接" 192.168.0.133
1.命令窗口配置网络连接指定IP netsh interface ip set address "本地连接" static IP地址 子网掩码 默认网关 例:netsh interface ip set address 10.1.1.1 255.255.255.1 10.1.1.123 DNS配置 netsh interface ip set dns name="本地连接" source=static addr=DNS服务器地址 register=PRIMARY v