Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 建立批次檔一鍵切換 IP 位址,出差攜帶筆電必學技巧

編輯:Win7 常見問題解答

頻繁攜帶筆電在不同網路環境(公司、家裡、客戶端)切換,每次手動設定 IP 極為繁瑣。撰寫簡單的批次檔(.bat),儲存多組 IP 設定,雙點即可秒切換,效率倍增。

建立步驟

  1. 桌面右鍵→【新增】→【文字文件】,命名為 ChangeIP.bat(副檔名必為 .bat)。
  2. 以記事本開啟,貼入以下程式碼並依實際環境修改參數:
@echo off
rem 網卡名稱(可在網路連線中查看,如「乙太網路」或「無線網路連線」)
set eth="無線網路連線"
rem 目標 IP 位址
set ip=192.168.1.8
rem 閘道位址
set gw=192.168.1.1
rem 子網路遮罩
set netmasks=255.255.255.0

echo 正在將本機 IP 變更為: %ip%
if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul
if not %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% 1 > nul

echo ..................
echo 檢查目前本機 IP:
ipconfig
echo ..................
echo 成功將本機 IP 變更為 %ip%!
pause
close
  1. 儲存關閉。需要切換 IP 時,以系統管理員身分執行該 .bat 檔即可。

可建立多個 .bat 檔對應不同地點,檔名標註地點(如 IP_Company.bat、IP_Home.bat),一鍵切換零負擔。

Copyright © Windows教程網 All Rights Reserved