高手帮忙写一段VBS,内容是自动选择网络配置

来源:百度知道 编辑:UC知道 时间:2024/05/21 22:01:15
因为同事们经常出差,不同的地方网络配置不一样,经常改来改去挺麻烦。所以烦请高手帮忙写一个脚本,实现网络配置的自动选择。
1:自动分配IP,DHCP;
2:固定IP
3:自己填写一个配置

内容包括IP,掩码,网关,DNS。
如高手愿意帮忙,以100分相送。

bat脚本.假设你的网络连接叫“本地连接”
保存为*.bat或者*.cmd

@echo off
echo 选择一个网络:
echo 1 自动获取
echo 2 192.168.x.x
echo 3 192.168.x.x
set /p index=输入序号:
If %index%=1 (
netsh interface ip set address "本地连接" dhcp
netsh interface ip set dns "本地连接" dhcp
) else if %index%=2 (
REM 依次是:IP,子网掩码,网关,跃点数(一般给1就行了)
netsh interface ip set address "本地连接" static 192.168.x.x 255.255.255.0 1
netsh interface ip set dns "本地连接" 202.96.209.6
REM 备用DNS
netsh interface ip add dns "本地连接" xx.xx.xxx.xx

) else if %index%=3 (

REM 第二套配置
netsh interface ip set address "本地连接" static 192.168.x.x 255.255.255.0 1
netsh interface ip set dns "本地连接" 202.96.209.6
netsh interface ip add dns "本地连接" xx.xx.xxx.xx
)