How to Assign Static or Dynamic IP Address on Windows 7 Computer with a Single Touch?

Vivek Nayyar March 4, 2011 4

IP addresses can instantaneously be assigned to a Windows 7 computer using batch files. This means that you need to create appropriate batch files in order to assign both static or dynamic IP addresses to the computer. Below are the steps using which you will be able to create a batch file with .bat extension which when executed will assign a specified IP address to the machine. Also you will learn to create another batch file which will configure your Windows 7 computer to obtain IP address automatically from a DHCP server.

  1. Click on Start button.
  2. At the bottom of start menu search box type NOTEPAD and press Enter key.
  3. In the notepad type NETSH INTERFACE IPV4 SET ADDRESS “Local Area Connection” STATIC 192.168.0.2 255.255.255.0 192.168.0.1 command where 192.168.0.2 is the static IP address, 255.255.255.0 is the subnet mask and 192.168.0.1 is the default gatway for the computer. IP address given above is just an example and you can use any IP address as per your choice.
  4. Static Address

  5. Once you are done, you need to save this notepad file with .bat extension. To do so press ctrl+s keys together and from the opened box specify the name of the file with .bat extension between double quotes. For example, “IPCH.BAT”
  6. To run this file you need to right click on it and from the context menu select Run As Administrator.
  7. To configure your Windows 7 computer to obtain IP address automatically from DHCP server you need to create another batch file containing NETSH INTERFACE IPV4 SET ADDRESS NAME=”Local Area Connection” SOURCE=DHCP command.

Best Practices:

You can use this batch file to assign IP address easily and quickly. In case you need to change IP address you can modify this .bat file by right-clicking on it and selecting Edit. This practice will save you couple of clicks and lots of time.

4 Comments »

  1. Hamami August 21, 2011 at 10:26 am - Reply

    Wow, a very useful and practical information for me as a network school teacher in Indonesia. Thank you for this handy intruction.

  2. Brittany September 22, 2011 at 5:53 am - Reply

    Why is there no line for DNS?

  3. Usman November 23, 2011 at 6:41 am - Reply

    I finally got it for WINDOWS 7 – REALLY WORKS!

    U need to do 2 Batch File for it to Works !!
    Open your Notepad and type these :
    ———————————————————————–

    netsh int ip set address “local area connection” static 191.100.29.15 255.255.255.0 191.100.29.222 1

    ————————————————————————
    Then save it as a batch (.bat) file. This is for IP , Mask, and Gateway, you can change it whatever IP that you like, but dont forget to put 1(number) at the back of gateway.

    Another batch for DNS:
    Type inside another Notepad, save it as another (.bat) file. You can change the DNS as you prefer.
    ————————————————————————

    netsh int ip set dns “local area connection” static 202.188.0.123 primary

    ————————————————————————
    Remember to run the Batch file by Right Click at the batch file,
    Choose ” Run As Administrator”. That’s It.

    Sorry coz Only 1 DNS only & I could not joint the batch together. Im not expert on command line, but Im trying to help.

  4. Iftikhar Ali January 31, 2012 at 6:53 am - Reply

    Is there any security issue in Windows 7, if we run these IP change netsh batch file scripts?

Leave A Response »