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了