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)&&exit
cd /d "%~dp0"
netsh interface ip set address "ethernet2" static 192.168.1.10 255.255.255.0 192.168.1.0
把網卡設置為動態獲取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 "ethernet2" source=dhcp
貼入上述代碼之后,把TXT文件修改文件類型為bat,并保存。接著把你想要更改的哪個網卡名字改為"ethernet2",或者把腳本中的ethernet2改成你的網卡名字,最好網卡名字命名為英文。中文有可能出現亂碼,無法識別。
之后就可直接雙擊這個腳本來自動修改網卡ip了