2018年1月11日 星期四

使用CMD指令快速更改IP


建立一個批次檔,如:ChangeIP.bat,將底下內容貼近去儲存後執行執行
ps.常用IP依照實際需求改一下
************************************************************
@Echo off
cls
echo 快速更換IP
set NicName=乙太網路

rem 設定常用IP(ex:公司使用)
set IP=192.168.1.1
set MASK=255.255.255.0
set Gateway=192.168.1.254
set DNS1=168.95.1.1
set DNS2=8.8.8.8

:Start
cls
echo 1.自動取得IP(DHCP)
echo 2.設定常用IP(ex:公司使用)
echo 3.手動輸入IP
set /P select1=請選擇您要設定的方式:
if %select1%==1 goto Stage1
if %select1%==2 goto Stage2
goto Stage3


:Stage1
echo 自動取得IP中...
netsh interface ip set address %NicName% dhcp
netsh interface ip set dnsserver %NicName% dhcp
echo 自動取得IP完成
Pause
goto Stage4

:Stage2
cls
echo 常用IP設定中...
netsh interface ip set address %NicName% static %IP% %MASK% %Gateway% 1
netsh interface ip set dnsserver %NicName% static %DNS1%
netsh interface ip add dnsserver %NicName% %DNS2%
echo 常用IP設定完成
Pause
goto Stage4

:Stage3
cls
set /P inputIP=請輸入IP Adress:
set /P inputMASK=請輸入子網路遮罩:
set /P inputGateway=請輸入預設閘道:
set /P inputDNS1=請輸入主要DNS:
set /P inputDNS2=請輸入次要DNS:
echo IP設定中...
netsh interface ip set address %NicName% static %inputIP% %inputMASK% %inputGateway% 1
netsh interface ip set dnsserver %NicName% static %inputDNS1%
netsh interface ip add dnsserver %NicName% %inputDNS2%
echo IP設定完成
Pause
goto Stage4

:Stage4
cls
Echo 您目前的IP如下
ipconfig /all
pause

1 則留言:

  1. Water Hack Burns 2lb of Fat OVERNIGHT

    Well over 160000 women and men are trying a easy and secret "liquids hack" to burn 2lbs every night while they sleep.

    It's scientific and works on everybody.

    Just follow these easy step:

    1) Hold a clear glass and fill it with water half the way

    2) Now do this proven HACK

    so you'll become 2lbs lighter as soon as tomorrow!

    回覆刪除