馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
本帖最後由 tseng743 於 2021-10-1 15:09 編輯
適用於XP WIN7 WIN10 復制以下文字 副檔名為BAT 須有基本理念
----------------------------------------------------------------------------
@echo off
ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto Win7
ver | find "5.1" > nul
if %ERRORLEVEL% == 0 goto WinXP
:Win7
echo Running Windows 7 Script
%1 Mshta vbscript:CreateObject("Shell.Application").ShellExecute("Cmd.exe","/C ""%~0"" ::","","runas",1)(window.close)&&exit
set m=0
for /f "skip=3 tokens=4 delims= " %%a in ("netsh interface show interface") do (
set /a m+=1
set name!m!=%%a
set netname="%%a"
)
goto exit
:WinXP
echo Running Windows XP Script
for /f tokens^=1^,2^ delims^=^" %%j in ("netsh interface ip show config") do (
if "%%j"=="介面 " (
set netname="%%k"
))
:exit
:start
echo.
echo IP地址更改小工具
set IP=10.1.1.143
set MASK=255.255.255.0
set GATEWAY=10.1.1.253
set NAME=%netname%
echo.
echo 自動更改IP 請按 1
echo.
echo 手動更改IP 請按 2
echo.
echo 自動取得IP 請按 3
echo.
set /p KEY= [您的選擇是:]
IF NOT "%select%"=="" SET Choice=%select:~0,1%
if /i %KEY% == 1 goto ONE
if /i %KEY% == 2 goto TWO
if /i %KEY% == 3 goto TREE
echo "%select%" !! 選擇無效,請選擇:
echo.
GOTO Start
echo.
:ONE
echo 正在自動更改IP......
echo.
echo %NAME% %IP% %MASK% %GATEWAY%
echo.
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 (
netsh interface ip set dnsservers "%NAME%" static 8.8.8.8 primary
netsh interface ip add dnsservers "%NAME%" 168.95.1.1
) else (
netsh interface ip set dns %NAME% static 168.95.1.1 primary
netsh interface ip add dns %NAME% 8.8.8.8
)
netsh interface ip set address %NAME% static %IP% %MASK% %GATEWAY% 1
echo IP地址/子網掩碼/閘道器設定完成
goto end
:TWO
ECHO 您選擇了手工修改設定。
ECHO.
echo 預設IP地址是%IP%,回車輸入預設地址
echo.
set /p IP= [請輸入IP地址:]
echo.
echo 預設MASK是%MASK%,回車輸入預設值
echo.
set /p MASK= [請輸入 子網掩碼 地址:]
echo.
echo 預設GATEWAY是%GATEWAY%,回車輸入預設值
echo.
set /p GATEWAY= [請輸入 閘道器 地址:]
GOTO ONE
:TREE
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 (
netsh interface ip set dnsservers "%NAME%" static 8.8.8.8 primary
netsh interface ip add dnsservers "%NAME%" 168.95.1.1
) else (
netsh interface ip set dns %NAME% static 168.95.1.1 primary
netsh interface ip add dns %NAME% 8.8.8.8
)
netsh interface IP Set Address %NAME% DHCP
echo 已將IP地址由靜態切換成動態,按任一鍵結束,……
:end
echo.
ipconfig/all
pause |