This walk through explains to create a batch file for switching between different ISP.
When there is a need to switch between different ISP’s and every time it’s a pain to remember all the IP addresses and fill out correctly in all those field of IP address, Subnet mask, Default gateway and DNS servers respectively.
To make things easier, let’s create a batch file which will do all these setting with in some seconds we can switch between different ISP.
To start with. Open a notepad and copy below lines and save it as some filename.bat. I have tested this with my machine IP address, which you need to change as per your machine IP, default gateway and DNS address and double click that batch file to switch between different ISP.
@echo off REM *** Settings1 First ISP REM "192.168.1.30" --- CHange the IP as your required machine IP set varip=192.168.1.30 set varsm=255.255.255.0 set vargw=192.168.1.11 set vardns1=192.168.1.1 set vardns2=202.96.126.68 REM *** Settings2 Second ISP --- CHange the IP as your required machine IP set varip2=192.168.1.30 set varsm2=255.255.255.0 set vargw2=192.168.1.11 set vardns3=192.168.1.1 set vardns4=8.8.8.8 echo Choose: echo ## Please check the connected network name should be "Local Area Connection" ## echo [F] Set Static IP for First ISP echo [S] Set Static IP for Second ISP echo [C] Set Static IP as Custom echo [D] Set as DHCP (Dynamic IP) echo. :choice SET /P E=[F,S,C,D] ? = for %%? in (F) do if /I "%E%"=="%%?" goto F for %%? in (S) do if /I "%E%"=="%%?" goto S for %%? in (C) do if /I "%E%"=="%%?" goto C for %%? in (D) do if /I "%E%"=="%%?" goto D goto choice :C @echo off echo "Please enter Static IP Address Information" echo "Static IP Address:" set /p IP_Addr= echo "Default Gateway:" set /p D_Gate= echo "Subnet Mask:" set /p Sub_Mask= echo "Please enter Static DNS Information" echo "Prefered DNS Address:" set /p Pre_DNS_Addr= echo "Alternate DNS Address:" set /p Alt_DNS_Addr= echo "Setting Static IP Information" netsh interface ipv4 set address "Local Area Connection" static %IP_Addr% %Sub_Mask% %D_Gate% 1 netsh interface ipv4 set dns name = "Local Area Connection" source = static addr = %Pre_DNS_Addr% netsh interface ipv4 add dns name = "Local Area Connection" addr = %Alt_DNS_Addr% pause goto end :D @ECHO OFF ECHO Resetting IP Address and Subnet Mask For DHCP netsh interface ipv4 set address "Local Area Connection" source = dhcp netsh interface ipv4 set dns "Local Area Connection" dhcp pause goto end :F netsh interface ipv4 set address "Local Area Connection" source = dhcp netsh interface ipv4 set dns "Local Area Connection" dhcp REM *** Settings1 ECHO Setting IP Address Subnet Mask and Default GateWay netsh interface ipv4 set address name = "Local Area Connection" source = static %varip% %varsm% %vargw% ECHO Setting Primary DNS netsh interface ipv4 set dns name = "Local Area Connection" source = static addr = %vardns1% ECHO Setting Secondary DNS netsh interface ipv4 add dns name = "Local Area Connection" addr = %vardns2% goto end pause :S netsh interface ipv4 set address "Local Area Connection" source = dhcp netsh interface ipv4 set dns "Local Area Connection" dhcp REM *** Settings2 ECHO Setting IP Address Subnet Mask and Default GateWay netsh interface ipv4 set address name = "Local Area Connection" source = static %varip2% %varsm2% %vargw2% ECHO Setting Primary DNS netsh interface ipv4 set dns name = "Local Area Connection" source = static addr = %vardns3% ECHO Setting Secondary DNS netsh interface ipv4 add dns name = "Local Area Connection" addr = %vardns4% goto end :end ECHO Here are the new settings for %computername%: ipconfig/release "Local Area Connection" ipconfig/renew "Local Area Connection" ipconfig/all ECHO. :PrintBright powershell -Command Write-Host "Settings applied successfully " Press any key to exit from this window..." -foreground "Red" Pause > nul
Through above steps we can switch between ISP while using Local Area Connection (Wired)
To switch between ISP while using Wireless Area Connection. Just edit the batch file and replace all Local Area Connection with Wireless Area Connection and save with a filename.bat..