1.创建一个txt文件,并把贴入如下代码:
把网卡设置ip为192.168.123.10 掩码255.255.255.0 网关192.168.123.1
@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
netsh interface ip set address "ethernet" static 192.168.123.10 255.255.255.0 192.168.123.1
把网卡设置为动态获取ip
@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
netsh interface ip set address "ethernet" source=dhcp
贴入上述代码之后,把 .TXT文件后缀修改文件名为.bat 并保存。接着把你想要更改的本地网卡名字改为"ethernet",或者把脚本中的ethernet改成你的网卡名字,最好网卡名字重命名为英文。中文有可能出现乱码,无法识别。
之后就可直接双击这个脚本来自动修改网卡ip了