脚本修改IP

修改无线网卡的静态IP

@echo off
%1 %2
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :Admin","","runas",1)(window.close)&goto :eof
:Admin
echo 网卡列表:
netsh interface show interface
set /p "mylnk=输入网卡名(有空格的请用英文双引号""包裹) : "
:: set mylnk="WLAN"
echo 1.设置静态IP
echo 2.设置为DHCP
echo 3.设置DNS
echo 4.退出

set /p "lan=请选择模式: "
if %lan%==1 goto static
if %lan%==2 goto dhcp
if %lan%==3 goto setdns
if %dns1%==4 goto end

echo "错误"
pause
exit

:dhcp
netsh interface ip set address name=%mylnk% source=dhcp
echo 配置成功
pause
exit

:static
set /p "myip=请输入IP : "
:: set myip="192.168.56.2"
set /p "mask=请输入掩码 : "
:: set mask="255.255.255.0"
set /p "gway=请输入网关 : "
:: set gway="192.168.56.254"
netsh interface ip set address name=%mylnk% source=static addr=%myip% mask=%mask% gateway=%gway% gwmetric=1
goto dns


:dns
echo 1.设置DNS地址
echo 2.退出

set /p "d=请选择: "
if %d%==1 goto setdns
if %d%==2 goto end

:setdns
set /p "mydns1=请输入首选DNS : "
netsh interface ip set dns name=%mylnk% source=static addr=%mydns1% register=primary

set /p "n=是否设置别用DNS(y/N):"
if "%n%"=="y" goto setdn
echo 配置成功
pause
exit

:setdn
set /p "mydns2=请输入备用DNS : "
netsh interface ip add dns name=%mylnk% addr=%mydns2%
echo 配置成功
pause
exit

:end
exit