BAT腳本實現(xiàn)自動IP地址切換?
BAT自動IP地址切換腳本如下:
@echo off color 3f mode con cols=80 lines=30 title 自動IP地址切換腳本 By 小強 if "%1"=="1" goto office if "%1"=="2" goto Home if "%1"=="3" goto dhcp :start cls echo= echo ============================================================================ echo= echo 1.切換到辦公室IP echo= echo 2.切換到家里的IP echo= echo 3.切換到自動獲取 echo= echo 0.退·出·腳·本 echo= echo ============================================================================ echo= set choice= set /p choice=請輸入你的選擇: if "%choice%"=="1" goto office if "%choice%"=="2" goto Home if "%choice%"=="3" goto dhcp if "%choice%"=="0" exit echo 輸入有誤,請重新選擇! pause>nul goto start :office cls cls echo. echo 正在設(shè)置IP為辦公IP請等待... echo. set net_interface="本地連接" echo 設(shè)置IP中... netsh interface ip set address "%net_interface%" source=static addr=192.168.0.5 mask=255.255.255.0 echo 設(shè)置IP成功...設(shè)置網(wǎng)關(guān)中... netsh interface ip set address name="%net_interface%" gateway=192.168.0.1 gwmetric=1 echo 設(shè)置網(wǎng)關(guān)成功...設(shè)置DNS中... netsh interface ip set dns "%net_interface%" static 202.98.0.68 netsh interface ip add dns "%net_interface%" 202.98.5.68 index=2 echo IP已成功切換到辦公設(shè)置,任意鍵返回... pause>nul goto start :home cls echo. echo 正在設(shè)置為家用IP請等待... echo. set net_interface="本地連接" echo 設(shè)置IP中... netsh interface ip set address "%net_interface%" source=static addr=192.168.1.111 mask=255.255.255.0 echo 設(shè)置IP成功...設(shè)置網(wǎng)關(guān)中... netsh interface ip set address name="%net_interface%" gateway=192.168.1.1 gwmetric=1 echo 設(shè)置網(wǎng)關(guān)成功...設(shè)置DNS中... netsh interface ip set dns "%net_interface%" static 218.85.152.99 netsh interface ip add dns "%net_interface%" 218.85.157.99 index=2 echo IP已成功切換到辦公設(shè)置,任意鍵返回... pause>nul goto start :DHCP echo. echo 正在設(shè)置IP為自動獲取,請等待... echo. set net_interface="本地連接" echo 設(shè)置IP中... netsh interface ip set address name="%net_interface%" source=dhcp echo 設(shè)置網(wǎng)關(guān)成功...設(shè)置DNS中... netsh interface ip set dns "%net_interface%" source=dhcp echo 設(shè)置成功!按任意鍵返回選擇菜單。 pause>nul GOTO start
到此這篇關(guān)于BAT腳本實現(xiàn)自動IP地址切換 的文章就介紹到這了,更多相關(guān)BAT IP地址切換 內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Chdir (Cd) 顯示當(dāng)前目錄的名稱,或更改當(dāng)前的文件夾
Chdir (Cd) 顯示當(dāng)前目錄的名稱,或更改當(dāng)前的文件夾...2007-09-09%1?mshta?vbscript之管理員權(quán)限運行bat的解讀
最近發(fā)現(xiàn)很多朋友咨詢%1?mshta?vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c?"^&chr(34)^&"%~0"^&chr(34)^&"?::","%cd%","runas",1)(window.close)&&exit的意思,這里就為大家簡單介紹一下2023-05-05實現(xiàn)WIN2003 IIS最小權(quán)限分配的批處理
實現(xiàn)WIN2003 IIS最小權(quán)限分配的批處理...2007-08-08批處理獲取網(wǎng)卡名稱的代碼(附修改IP、網(wǎng)關(guān)、DNS腳本)
此腳本使用于因為網(wǎng)卡換過PCI槽,導(dǎo)致的網(wǎng)卡名稱帶有2,3,4的情況。2011-03-03應(yīng)用dos批處理文件經(jīng)常用到的DOS常用命令
應(yīng)用dos批處理文件經(jīng)常用到的DOS常用命令...2007-03-03