|
-
Mar 12th, 2006, 11:25 AM
#1
Thread Starter
New Member
Changing Ip adress, gateway & subnet mask of a connection
Hi i'm trying to make a tool that can change a connections Ip address, gateway address and subnet mask. This is instead of going into Network connections -> Lan properties -> Internet protocol properties in windows. I know i can find the address using winsock. But how do i change it ?? Any suggestions , tips or tricks??
Thanks
-
Mar 16th, 2006, 05:08 PM
#2
Frenzied Member
Re: Changing Ip adress, gateway & subnet mask of a connection
You can change it using WMI classes. Take a look at this class. I believe most of what you want to do is taken care of here.
http://msdn.microsoft.com/library/de...l/anch_wmi.asp
-
Mar 16th, 2006, 05:10 PM
#3
Re: Changing Ip adress, gateway & subnet mask of a connection
Welcome to VBF 
netsh is a great commandline tool.
Just open a console and type "netsh"
Using "?" on each command should help you through it.
Although, for chnging this stuff programatically, WMI is a better way to go if you can make it work (it will be alot cleaner).
-
Dec 22nd, 2006, 05:16 AM
#4
PowerPoster
Re: Changing Ip adress, gateway & subnet mask of a connection
this is an old post, but here is the WMI for changing to Static ..
Includes IP, Subnet, Gateway, and DNS. Just leave out the DNS if you dont need it.
VB Code:
Sub Set_Static()
Dim objWMIService, colNetAdapters, objNetAdapter
Dim strIPAddress, strSubnetMask, strGateway, strGatewaymetric, strDNS
Dim errEnable, errGateways, errDNS
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration " _
& "where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.101")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
strGatewaymetric = Array(1)
strDNS = Array("10.10.10.10", "10.10.10.11")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS)
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|