疑难解答-windows快速批處理更換IP

做了兩個批處理用於快速切換IP和網關。

  @echo off

  rem eth //eth 為網卡名稱,可在網絡連接中查詢,如”本地鏈接”

  set eth=”無線網絡連接”

  rem ip //ip 為妳想更改的IP

  set ip=192.168.1.8

  rem gw //gw 為網關地址

  set gw=192.168.1.1

  rem netmasks //netmasks 為子網掩碼

  set netmasks=255.255.255.0

  echo 正在將本機IP更改到: %ip%

  rem

  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