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

    • Taiwan hits Huawei and SMIC with new export restrictions by David Uzondu Taiwan has added Huawei and Semiconductor Manufacturing International Corporation, or SMIC, to its export control entity list. According to CNBC, this means companies in Taiwan now need a special license to ship certain high-tech goods to these two mainland Chinese firms. The conflict has been escalating for a while. The United States government, for instance, has been going after Huawei since at least 2019, putting the telecom equipment maker on its own Entity List over national security fears. The worry has always been about Huawei's connections to the Chinese government and the potential for its network gear to be used for spying. The United Kingdom eventually followed suit, ordering all Huawei 5G equipment to be ripped out of its networks by 2027. Remember, in December 2020, the US added SMIC to its Entity List over its alleged ties to the Chinese military. The goal was to choke off the chipmaker's access to the tools it needs to produce the most advanced semiconductors. Despite all the pressure, the two firms managed to collaborate and produce a 7nm chip for Huawei's Mate 60 phone, which annoyed some people in Washington who thought the sanctions had completely crippled China's chipmaking ambitions. This new blacklisting from Taiwan just tightens the screws even more. Last year, research firm TechInsights found a TSMC-made chip inside a Huawei AI training card. That was a huge "oh no" moment because it showed that, despite all the American restrictions, Huawei was still getting its hands on advanced Taiwanese silicon. That discovery led directly to the U.S. Commerce Department leaning on TSMC to shut down access for Chinese clients to specific AI chips. Huawei had cleverly exploited loopholes to hoard millions of GPU dies for its Ascend AI chip program, a direct attempt to build a homegrown alternative to Nvidia's dominant hardware. For Taiwan, this feels less like a trade issue and more like a matter of survival. The island's lead in chipmaking, largely thanks to TSMC, is often seen as its "silicon shield." The idea is that global reliance on Taiwanese chips makes any military action by China a huge risk for the world. Letting its most advanced tech reach the country that threatens its very existence could seriously weaken that shield. Source: CNBC
    • Anything is "news worthy" if it's new and someone writes about it. Something like an inconsequential note about "correcting a typo in the readme file" buried deep in the changelog could become "news worthy". And, on related note, anything can be used as a justification to complain about something one is clearly already biased against. Say, if someone's biased against Windows 11, they could see even an inconsequential change like an added time display as a reason to rant about "Microsoft these days"... ¯\_(ツ)_/¯
    • I expect i will always have the choice, I doubt I will be around to see self drive cars on the roads in any great amounts. I can understand where your wife is coming from, but then being in a car alone can have other problems.
    • I have no interest in changing to Windows 11, even if I update my PC. My Pc can run it unofficially, and I have had a peek now and again, but so many things that put me off, All the AI stuff that is all over the place, so not an easy way to switch it off, the forced MS account, the way Windows 11 pops up dialogues when you are not using Edge or any other MS supplied software. The awful context menus. The search in windows using Bing and then the results in Edge. There are other reason. I changed to Mac for the most part, but as I have said before, I do have an old AMD R 7 1700 machine for my games, unless it stops working I will keep it going with Windows 10.
    • I switched to Mac, I would have changed to Linux, but i run software that is no compatible with Linux and no replacement.
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      615
    2. 2
      ATLien_0
      277
    3. 3
      +FloatingFatMan
      180
    4. 4
      Michael Scrip
      150
    5. 5
      Steven P.
      115
  • Tell a friend

    Love Neowin? Tell a friend!