Change your IP using batch file
73A batch file is a text file containing a series of commands intended to be executed by the command interpreter.
If you want a series of command to be executed because you are tired of typing every command over and over again then you should create a batch file.
When a batch file is run, the shell program (usually
command.com
or
cmd.exe
) reads the file and executes its commands, normally line-by-line.
Too much words lets proceed on why you have to use a batch file in changing the ip when you can do it by just clicking using your mouse.
I have this situation where i have to connection. One is for the internet and one is for another and i only have one computer and one cable or UTP wire so i have to change everytime i want to use one of it. Heres the code on how to change the IP address so that you will just click on the batch file and tadah.... Your IP will change in just a second.
Just copy the codes below and paste it in "notepad" and in saving it put a double quote on the filename. Example: "Change IP.bat".
Because if you if you don't put a double quote in the filename then notepad will save it as "Change IP.bat.txt"
Double click the batchfile to execute.
@ECHO OFF
set varip=192.168.1.68
set varsm=255.255.255.0
set vargw=192.168.1.1
set vardns1=192.168.1.1
set vardns2=192.168.1.1
set varhome=www.google.com
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask
= %varsm%
ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1
ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%
ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%
ECHO Setting Internet Explorer Homepage to %varhome%
reg add "hkcusoftwaremicrosoftinternet explorermain" /v "Start Page" /d "%varhome%" /f
NOTE:
Change the values of the variables to your desired IP.
Try to see the IP configuration in windows and you will see the corresponding values.
- set varip=192.168.1.68 for IP Address
- set varsm=255.255.255.0 for Subnet Mask
- set vargw=192.168.1.1 for Default gateway
- set vardns1=192.168.1.1 for Preferred DNS server
- set vardns2=192.168.1.1 for Alternate DNS server
- set varhome=www.google.com for Home Page
My featured hubs
- Counter Strike cheats and tips
Important: This counter strike cheats works and tested on version 1.3. Just try this if it will work on higher version of counter strike. To activate cheats, type in the consolesv_cheats 1Then... - 6 months ago
- NTLDR is missing
Related errors: NTLDR is missing press any key to restart Boot: Couldn't find NTLDR ... - 2 years ago
- Sony Ericsson PC Suite
This version of Sony Ericsson PC suite was downloaded from the Sony Ericsson website. Some SE PC Suite that came with a brand new handset is a lower version of this PC Suite. Main functionalities... - 5 months ago
PrintShare it! — Rate it: up down flag this hub
Comments
try using 255.255.255.224
or try to configure it manually
Use obtain IP address automatically then click ok, then use the IP address manually. When you inputted the IP adress then press tab the Subnet mask will generate automatically then you can use that subnet in the batch file.
Now i know the problem of that. i copied the batchfile and i notice that there are some spaces thats why it becomes error.
I already fix the codes.
Wow i didn't know we can change IP using batch file. Thank you for this hub.











marc says:
5 months ago
for Subnet Mask-255.255.255.0 is not recognized as an internal or external command operable program or batch file
this is what my pc tells me,do you know whats the problem?