Windows下bat脚本修改网卡ip

1.创建一个txt文件,并把贴入如下代码:
 
把网卡设置ip为192.168.1.10 掩码255.255.255.0 网关192.168.1.0
 
@echo off%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exitcd /d "%~dp0"netsh interface ip set address "ethernet2" static 192.168.1.10 255.255.255.0 192.168.1.0 

Windows下bat脚本修改网卡ip

文章插图
 
把网卡设置为动态获取ip
 
@echo off%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exitcd /d "%~dp0"netsh interface ip set address "ethernet2" source=dhcp  
Windows下bat脚本修改网卡ip

文章插图
 
贴入上述代码之后,把TXT文件修改文件类型为bat,并保存 。接着把你想要更改的哪个网卡名字改为"ethernet2",或者把脚本中的ethernet2改成你的网卡名字,最好网卡名字命名为英文 。中文有可能出现乱码,无法识别 。
 
之后就可直接双击这个脚本来自动修改网卡ip了

【Windows下bat脚本修改网卡ip】


    推荐阅读