Create a Batch File to Easily Refresh Network Settings

Posted on March 23, 2008
Filed Under How To, Networking, Windows | 10 Comments

Program IconIf you are an emerging computer tech and you haven’t already become accustom to using the ipconfig command, you soon will.  This command is most commonly used at the DOS prompt to see a computer’s current IP configuration.  Using this command with three different switches also allows you to refresh a computer’s network settings which can be very useful when troubleshooting network issues.  In the following tutorial, I would like to show you how you can create a batch file that will run this command along with its switches to quickly refresh a computer’s network settings.


Before we get started, it might be helpful for you to first understand what a batch file is.  A batch file is a simple text file that can run a series of DOS commands when executed.  They can be created using Windows Notepad or any other plain text editor.  You simply enter the DOS commands that you would like to run and save the file with a .bat extension.  You can then execute it by simply double clicking on it.

Lets get started.

 

Step 1:  Click on the “Start” menu and go to “All Programs”.  Go to “Accessories” and open “Notepad”.

 

Step 2:  In Notepad, type in the following commands which will be run to refresh a computer’s network settings.

ipconfig /release
ipconfig /flushdns
ipconfig /renew

It should look like this.
Batch File 1 Screenshot

The “release” switch will release your current IP address settings.  The “flushdns” switch will flush the DNS resolver cache.  The “renew” switch will renew your IP address settings.

 

Step 3:  Now click on the “File” menu and select “Save As”.  Change the “Save As Type” field to “All Files” located near the bottom of the window.  Now enter a “File Name” such as “Refresh.bat” without the quotes.  It is important that you put the .bat extension on the end of the file name or you will not be able to execute it as a batch file.  Choose a “Save In” location and click the “Save” button to save it.
Batch File 2 Screenshot

 

Step 4:  Now you can run your new batch file by double clicking on it.
Batch File 3 Screenshot

 

After the batch file has finished executing, the computer’s network settings will be refreshed.
Batch File 4 Screenshot

 

You can put this file on your desktop for quick access or on a flash drive to use on other computers.  It can be run on any Windows machine including XP and Vista.  Remember, these commands will only work if the computer is set up to obtain an IP address automatically and will not work if the computer has a hard-coded IP address.

If you have any experience using batch files, please feel free to share what you use them for.

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Twitter
  • Facebook
  • Google Bookmarks
  • email
  • Print
If you enjoyed this post, make sure you subscribe to my RSS feed!


Other Posts You Might Like:

Comments

10 Responses to “Create a Batch File to Easily Refresh Network Settings”

  1. Casey on April 6th, 2008 9:01 pm

    Wow, thanks for sharing this with us.  I created one on my computer and it worked like a charm.  I love the menus and even the change of color.

    Reply

  2. Anonymous on June 8th, 2008 9:15 pm

    Hi, I just created the refresh.bat with your instructions and found out that it does not work if I just double click it in Vista. I have to actually right click and use the ‘Run as adminstrator’ option to get it to work.

    Is there any way around this? I do not want to diable my UAC function in my Vista, just thinking of creating something like a special permission thing for this particular refresh.bat.

    Thanks!

    Reply

  3. Anonymous on July 10th, 2008 7:38 am

    add this to the front of the batch file:

    runas /user:local\administrator

    it will prompt you for the admin password. It just does the run as part for you.

    Reply

  4. Anonymous on April 1st, 2008 9:17 pm

    Thanks to your idea, I created my own file. (I took out the ascii graphics in the Menu’s).

    @echo off
    title NETWORK RESET SCRIPT
    :prompt
    color 1f
    cls
    echo NETWORK RESET SCRIPT
    echo.
    echo Type r to Reset Network
    echo Type p to do a ping test
    echo Type c to go to Command Prompt
    echo Type q to exit
    set /p answer=
    if ‘%answer%’ == ‘r’ goto test
    if ‘%answer%’ == ‘R’ goto test
    if ‘%answer%’ == ‘C’ goto cmd
    if ‘%answer%’ == ‘c’ goto cmd
    if ‘%answer%’ == ‘q’ goto quit
    if ‘%answer%’ == ‘Q’ goto quit
    if ‘%answer%’ == ‘P’ goto ping
    if ‘%answer%’ == ‘p’ goto ping
    pause >nul

    :test
    cls
    echo —————————————————-
    echo – RELEASING IP…. -
    echo —————————————————-
    ipconfig /release >nul
    echo.
    echo Done!
    echo.
    echo —————————————————-
    echo – RESETTING IP LOG… -
    echo —————————————————-
    @netsh int ip reset C:\Windows\TEMP\IPRESETLOG.txt >nul
    echo.
    echo Done!
    echo.
    echo —————————————————-
    echo – FLUSHING ARP TABLES… -
    echo —————————————————-
    @arp -d >nul
    echo.
    echo Done!
    echo.
    echo —————————————————-
    echo – FLUSHING DNS… -
    echo —————————————————-
    @ipconfig /flushdns >nul
    echo.
    echo Done!
    echo.
    echo —————————————————-
    echo – RENEWING IP… -
    echo —————————————————-
    @ipconfig /renew >nul
    echo.
    echo Done!
    echo.
    cls
    echo —————————————————-
    echo Heres Your Status: -
    echo —————————————————-
    ipconfig /all
    echo.
    echo Press Any Key to Go To Menu
    pause >nul
    goto prompt

    :ping
    cls
    echo —————————————————-
    echo Starting Ping Test… -
    echo —————————————————-
    echo.
    ping google.com
    echo.
    echo Press Any Key to goto MENU
    pause >nul
    goto prompt

    :quit
    cls
    echo Thanks For Using The Network Reset Script
    pause
    exit

    :cmd
    @color 7
    cls
    cmd
    @echo on

    Reply

  5. Yamaha on September 11th, 2008 1:06 pm

    This is wonderful. Thanks fellas.

    Reply

  6. sandeep on December 17th, 2008 8:58 am

    This is great … it works wonders…

    Reply

  7. Rav on April 16th, 2009 3:40 am

    Hi I have copied the above script and created .vbs file when running the file i get Windows Script Host error
    Line: 1
    Char 1
    Error: Invalid Character
    Code: 800A0408
    Source: Microsoft VBScript compilation error

    Can you help please?

    Reply

    Rav Reply:

    I have solved the issue. saved file as .BAT and it works… Doh!!!!

    Cheers mate.

    Reply

  8. mukesh on January 18th, 2010 11:31 pm

    hello sir i m using two ip address in one machine
    so how to create a bat file & how to create a diffrent ip address in bat file pls sent my email id

    Reply

  9. Psycho-Smiles on May 13th, 2010 4:10 am

    cmd /k ipconfig /displaydns to display DNS

    cmd /k ipconfig /flushdns to flush DNS

    make 2 seperate bats so you can see your recent activity if you want to without it wiping your DNS out first

    save as DNS.bat etc

    Reply

Leave a Reply