批處理修改IP設定

2021-04-12 13:29:45 字數 3136 閱讀 9419

@echo off

clscolor 0a

echo **************************************

echo *ip位址快速切換 [email protected]*

echo **************************************

set ip=192.168.100.100

set mask=255.255.254.0

set gateway=192.168.100.254

set dns1=192.168.100.1

set dns2=202.115.32.39

set inte***ce=本地連線

:menu

echo.

echo 快速設定請按 1

echo.

echo 手工設定請按 2

echo.

echo 建立預設請按 3

echo.

echo 自動獲取請按 4

echo.

echo 察看狀態請按 5

echo.

echo 退出請按任意鍵

echo.

set /p key= [請輸入您的選擇:]

if %key% == 1 goto quick

if %key% == 2 goto manual

if %key% == 3 goto default

if %key% == 4 goto dhcp

if %key% == 5 goto look

if %key% == "" goto end

goto end

:look

echo.

ipconfig

echo.

echo 本程式預設修改的是「本地連線」的設定

echo.

echo 需要修改請按相應的數字鍵,

echo.

echo 例如:輸入2表示改為「本地連線 2」

echo.

echo 英文作業系統請按e2,任意鍵繼續!

echo.

set /p intemp= [請輸入本地連線的編號]

if %intemp% == 1 set inte***ce=本地連線

if %intemp% == 2 set inte***ce=本地連線 2

if %intemp% == 3 set inte***ce=本地連線 3

if %intemp% == 4 set inte***ce=本地連線 4

if %intemp% == 5 set inte***ce=本地連線 5

if %intemp% == e1 set inte***ce=local area connection

if %intemp% == e2 set inte***ce=local area connection 2

if %intemp% == e3 set inte***ce=local area connection 3

if %intemp% == e4 set inte***ce=local area connection 4

if %intemp% == e5 set inte***ce=local area connection 5

clsgoto menu

:quick

if not exist ip.txt copy con ip.txt

if exist ip.txt goto qdo

echo.

echo 沒有發現預設設定檔案!

goto end

:qdo

netsh -f ./ip.txt

echo.

echo 按照預設設定已經完成設定!

goto end

:default

netsh -c inte***ce ip dump > ./ip.txt

echo.

echo 預設設定已經生成!

goto end

:dhcp

echo.

echo 快速設定ip位址和dns為「自動獲得」

echo.

netsh inte***ce ip set address "本地連線" dhcp

netsh inte***ce ip set dns "本地連線" dhcp

goto end

:manual

echo.

echo 您選擇了手工修改設定。

echo.

:list

echo 即將對「%inte***ce%」進行設定

echo 即將生效的 ip 位址是%ip%

echo 即將生效的 mask 是%mask%

echo 即將生效的gateway位址是%gateway%

echo 即將生效的 主dns 位址是%dns1%

echo 即將生效的第二dns位址是%dns2%

echo.

set /p reen= [馬上更改請按 1,重新設定請按 2,退出請按任意鍵]

if %reen% == 1 goto do

if %reen% == 2 goto manual

goto end

:doecho.

echo 正在更改ip......

echo.

echo ip位址及子網掩碼設定完成

netsh inte***ce ip set address name="%inte***ce%" source=static addr=%ip% mask=%mask%

echo 閘道器位址設定完成

netsh inte***ce ip set address name="%inte***ce%" gateway=%gateway% gwmetric=0

echo 主dns位址設定完成

netsh inte***ce ip set dns name="%inte***ce%" source=static addr=%dns1% register=primary

echo 第二dns位址設定完成

netsh inte***ce ip add dns name="%inte***ce%" addr=%dns2% index=2

goto end

:end

echo.

pause

批處理修改IP

上次乙個要我做的乙個ip轉換的批處理,貼出來給大家使用.可以在2個ip之前相互轉換,不必再去修改本地連線了,你要做的只是輸入1或者2。請按自己的須求做相應的修改,原始碼如下 echo off title ip轉換工具 powered by px mode con cols 40 lines 10 c...

批處理設定IP

有些公司加入域後影響一些正常的上網行為,這個時候需要設定靜態ip,下面乙個批處理檔案 可以自動設定ip echo off netsh inte ce ip set address name 本地連線 source static addr 10.16.252.77 mask 255.255.252.0...

批處理設定IP位址

echo 現在開始設定本機網路位址 echo 現在開始設定本機ip netsh inte ce ip set address 本地連線 source static addr 172.31.13.199 mask 255.255.254.0 echo 現在開始設定本機gateway netsh int...