Jump to content

How to change a network settings programmatically?


Serg

Recommended Posts

Hi all,

Is there a way to programmatically change every network setting that is available through network connections in explorer?

I mean when you right click on local area connection->select properties->networking tab->tcpip->properties. There you can change the ip address, subnet mask, default gateway, dns.

I want to know exactly how does the windows explorer changes these settings (programmatically).

Thank you,

Serg.

Link to comment
Share on other sites


  • Replies 16
  • Views 1.3k
  • Created
  • Last Reply

The settings are changed in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}

"EnableDHCP"

"IPAddress"

"SubnetMask"

"DefaultGateway"

and other settings everything is there!

Not actually sure if something changes if you play with the values, you can try it if you want to find out!

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx} = I have a few of these, one should be your default settings.

Link to comment
Share on other sites


The parameters in HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\ is automatically laid out whenever you turn your computer on.

I believe if you mess with some parameters it can either make or break your internet connection.

Link to comment
Share on other sites


make sure u backedup ur registry incase of ne trouble <_<

Link to comment
Share on other sites


I can't help too much, but I remember an article in Computer Shopper where they use built in command line tools to save and restore interface configurations to and from a file. It was for a laptop to help it move between different locations. I'm afraid I cannot remember the command used, but there is one. You do not have to tinker with the registry.

Link to comment
Share on other sites


Thank you all for your replies, but isn't there some Windows API for that purpose?

If I change the values in the registry, I must reboot the PC for the changes to take effect.

Isn't Windows explorer uses some API to change these settings without rebooting?

By the way, the OS is XP PRO SP3.

Thank you,

Serg

Link to comment
Share on other sites


Here is how you set ip address, mask, gateway:

netsh interface ip set address name ="name of connection" source = static addr = xxx.xxx.xxx.xxx mask = xxx.xxx.xxx.xxx gateway = xxx.xxx.xxx.xxx gwmetric = 1

Here's how you restore it to automatic:

netsh interface ip set address name="name of connection" source=dhcp 

Cheers ;)

Link to comment
Share on other sites


Here is how you set ip address, mask, gateway:

netsh interface ip set address name ="name of connection" source = static addr = xxx.xxx.xxx.xxx mask = xxx.xxx.xxx.xxx gateway = xxx.xxx.xxx.xxx gwmetric = 1

Here's how you restore it to automatic:

netsh interface ip set address name="name of connection" source=dhcp 

Cheers ;)

Thank you for that,

so there are no API function that doing exactly the same as netsh?

Serg.

Link to comment
Share on other sites


Well maybe there is, but I'm not aware of it. But commands I gave you should solve your issue.

Cheers ;)

The commands you gave me definitely solved my issue, but not in a programmatically's elegant way.

Though thank you very much for this solution.

I am still waiting for someone who knows how to do it using a windows API functions.

Is it possible that Microsoft does not implemented such functions?

I have searched through MSDN library, and have not find any answers.

Serg.

Link to comment
Share on other sites


It's obvious there should be a WinAPI to do that, since all Wireless adaptors brands a custom conecction setup to set those parameters...

Thanks for netsh command mara- ;) It isn't suitable for programming, but it's nice for BATs.

Link to comment
Share on other sites


Hello all,

After a lot of googling, I have dug up this Windows API function: SetAdapterIpAddress.

I must say that it works perfectly for me, but the problem is that its undocumented and so may change with every update.

I can hardly believe that Microsoft has no such formal API function!

If someone knows anything about it, please advise!

Serg.

Link to comment
Share on other sites


Hi all,

Is there a way to programmatically change every network setting that is available through network connections in explorer?

I mean when you right click on local area connection->select properties->networking tab->tcpip->properties. There you can change the ip address, subnet mask, default gateway, dns.

I want to know exactly how does the windows explorer changes these settings (programmatically).

Thank you,

Serg.

You may like to have a peep here:- B)

Link to comment
Share on other sites


You may like to have a peep here:- B)

Thank you dcs18, I will check this ebook and report here if I will find anything useful.

Serg.

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...