Change IP address by just one click?


Recommended Posts

You can do this by creating 2 batch files.

1. First, change the IP address manually to the first IP address

2. Run a Command box and enter "netsh interface dump > c:\windows\ip1.txt" (without quotes) and press enter

3. Exit the Command Box

4. Now change the IP address manually again to the second IP address

5. Run a Command box and enter "netsh interface dump > c:\windows\ip2.txt" (without quotes) and press enter

Batch file 1:

@echo off
echo Changing IP Address to IP Address 1
netsh exec c:\windows\ip1.txt

Batch file 2:

@echo off
echo Changing IP Address to IP Address 2
netsh exec c:\windows\ip2.txt

Now all you have to do is run the appropiate batch file to configure the PC to use that IP address. Just remember not to delete the two text files created. And if you add a shortcut in the quick launch tool bar for each of the batch files, just one click to change like you requested.

Edited by john.porter

Just what i was looking for, thanks a lot =)

Edit: One weird thing though, default gateway stays blank where you normally change IP address, even though everything works fine. What's the reason for this?

Edited by Nitrius

Glad to be of help.

This can also be used to save your setting for backing up purposes or if you are re-formatting etc. If anyone is interested I have a batch file which will save, and restore setting if you pass it parameters and the name of the file.

  Nitrius said:
Just what i was looking for, thanks a lot =)

Edit: One weird thing though, default gateway stays blank where you normally change IP address, even though everything works fine. What's the reason for this?

Again, you have to manually set your network settings before creating this file. This works without fail for me on my Vista system.

Look in one of the text files for the following line:

set address name="<Name of your Connection>" gateway=XXX.XXX.XXX.XXX gwmetric=0 (where XXX.XXX.XXX.XXX is your gateway address)

Is that line there?

If not, Repeat Steps 1-5 again, making sure when you manually set the IP address you set the subnet mask, the default gateway and the dns server settings.....

It works, it's just that the gateway box is empty, though if you check details under customize in the vista network console you can see the gateway address, it's like it been inputted into another place.

Here is how the "dump" ip1/2.txt files looks:

#========================
# Interface configuration
#========================
pushd interface

reset all


popd
# End of interface configuration



# ----------------------------------
# IPv4 Configuration
# ----------------------------------
pushd interface ipv4

reset
set global icmpredirects=enabled
add route prefix=0.0.0.0/0 interface="Local Area Connection" nexthop=xxx.xxx.xxx.xxx
add address name="Local Area Connection" address=xxx.xxx.xxx.xxx


popd
# End of IPv4 configuration



# ----------------------------------
# IPv6 Configuration
# ----------------------------------
pushd interface ipv6

reset


popd
# End of IPv6 configuration



# ----------------------------------
# ISATAP Configuration
# ----------------------------------
pushd interface isatap



popd
# End of ISATAP configuration



# ----------------------------------
# 6to4 Configuration
# ----------------------------------
pushd interface 6to4

reset



popd
# End of 6to4 configuration



# ----------------------------------
# ISATAP Configuration
# ----------------------------------
pushd interface isatap



popd
# End of ISATAP configuration


\#========================
\# Port Proxy configuration
\#========================
pushd interface portproxy

reset


popd

# End of Port Proxy configuration



# ----------------------------------
# TCP Configuration
# ----------------------------------
pushd interface tcp

reset

set global rss=enabled chimney=disabled autotuninglevel=normal congestionprovider=none ecncapability=disabled timestamps=disabled


popd
# End of TCP configuration



# ----------------------------------
# Teredo Configuration
# ----------------------------------
pushd interface teredo
set state servername=teredo.ipv6.microsoft.com.



popd
# End of Teredo configuration



# ----------------------------------
# 6to4 Configuration
# ----------------------------------
pushd interface 6to4

reset



popd
# End of 6to4 configuration

Found another way:

netsh interface ip set address name="Local Area Connection" static IP-ADDRESS SUBNET-MASK DEFAULT-GATEWAY

Just added that into the batch files, one with each IP address, and it seems to work, just as your method did john, just that now the gateway doesn't disappear from the "default gateway" box.

Edited by Nitrius
  Nitrius said:
Found another way:

netsh interface ip set address name="Local Area Connection" static IP-ADDRESS SUBNET-MASK DEFAULT-GATEWAY

Just added that into the batch files, one with each IP address, and it seems to work, just as your method did john, just that now the gateway doesn't disappear from the "default gateway" box.

Fantastic. Glad you got it to work.

Yup calling netsh commands is the easiest fastest way to make changes to your ip and or other settings be it static or dhcp, dns, gateways, wins, etc.. etc.

But I am curious on why your needing to do this? If switching between network, do you not have dhcp? If this in home setup maybe you could change your networks around so you would not have to switch IPs etc.

If you gave us the details -- maybe it would be possible to allow you to do what your wanting to do with no clicks ;)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • All set as AI did the trick
    • AnyDesk 9.5.7 by Razvan Serea AnyDesk is a fast remote desktop system and enables users to access their data, images, videos and applications from anywhere and at any time, and also to share it with others. AnyDesk is the first remote desktop software that doesn't require you to think about what you can do. CAD, video editing or simply working comfortably with an office suite for hours are just a few examples. AnyDesk is designed for modern multi-core CPUs. Most of AnyDesk's image processing is done con­currently. This way, AnyDesk can utilize up to 90% of modern CPUs. AnyDesk works across multiple platforms and operating systems: Windows, Linux, Free BSD, Mac OS, iOS and Android. Just five megabytes - downloaded in a glimpse, sent via email, or fired up from your USB drive, AnyDesk will turn any desktop into your desktop in se­conds. No administrative privileges or installation needed. AnyDesk 9.5.7 changelog: Fixed Bugs Fixed deadlock when updating chat server Fixed crashes caused by exceptions in internal communication layer Fixed crash when opening new monitor in Session in a new window Fixed crash on shutdown Fixed bug that allowed naming Permission Profiles identical to predefined Profiles Fixed bug that could cause licensed remote clients to show up as free Fixed visual bug that caused Set-Password button to show up when Unattended Access was disabled Fixed bug that lead to selecting the wrong initial resolution for webcams New Features Added command line option --record-screen to start a Screen Recording Other Changes Improved visual consistency in some list views Download: AnyDesk 9.5.7 | macOS ~14.0 MB (Free for private use, paid upgrade available) Links: AnyDesk Home Page | Other platforms | Release History | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • WUT?! Tell us you've never built desktop software without telling us you've never built desktop software... The chromium rendering engine is the content-rendering engine for "chromium-based browsers," but that does NOT mean there's a full-on UI underneath that is somehow bloating these products. The bloat is from the additional UI components that the browser vendor (Vivaldi) is adding atop the base package. Most chromium browsers customize the default skin/theme of the overall package so there's absolutely zero added overhead; it's really just a different CSS-based theme pack. Vivaldi, however, adds more than just a different skin; they add built-in extensions (that are managed by other built-in extensions), add other customization modules, and all kinds of other bloat -- and these add-ons are EXACTLY where the resource-hogging stems from. The mere fact it's a chromium-based browser has no impact on the matter. Lastly, power users literally DO notice resource-intensive applications -- they'll even be familiar with tools and widgets that expose those measurements the way only a power-user would! General consumers, however, would simply remark that their rig is sluggish and probably outdated and blindly upgrade to whatever the salespeople are hawking at the local computer store. General consumers wouldn't even upgrade their existing computer cuz they wouldn't know how to!
    • Nope, they just removed the game from sales.
  • Recent Achievements

    • First Post
      Celilo earned a badge
      First Post
    • One Year In
      K.I.S.S. earned a badge
      One Year In
    • Week One Done
      solidox earned a badge
      Week One Done
    • Dedicated
      solidox earned a badge
      Dedicated
    • Week One Done
      Devesh Beri earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      438
    2. 2
      ATLien_0
      166
    3. 3
      +FloatingFatMan
      151
    4. 4
      Nick H.
      66
    5. 5
      macoman
      63
  • Tell a friend

    Love Neowin? Tell a friend!