Windows下bat指令碼修改網絡卡ip
阿新 • • 發佈:2019-01-06
1.建立一個txt檔案,並把貼入如下程式碼:
把網絡卡設定ip為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" static 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" source=dhcp
貼入上述程式碼之後,把TXT檔案修改檔案型別為bat,並儲存。接著把你想要更改的哪個網絡卡名字改為"ethernet2",或者把指令碼中的ethernet2改成你的網絡卡名字,最好網絡卡名字命名為英文。中文有可能出現亂碼,無法識別。
之後就可直接雙擊這個指令碼來自動修改網絡卡ip了。