can someone help me on how to set IP address using VB thanks
Printable View
can someone help me on how to set IP address using VB thanks
set IP address of what?
set IP address of my computer...
You could change the LAN address using some API's probably. What exactly do you want to achieve as the end result?
_Pulled this code from google
Edit: Seems to work. Does however break DNS server, work with it and see what you can get maybeCode:Dim objWMIService, colNetAdapters, objNetAdapter
Dim strIPAddress, strSubnetMask, strGateway, strGatewaymetric
Dim errEnable, errGateways
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration " & "where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
strGatewaymetric = Array(1)
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
Next
If you programmatically change the IP address of your computer, isn't that going to mess up connections for you? Do you have a static IP, or are you using DHCP?
Probably not as its probably the local ip of the workstation and not the router.
You can also shellexecute the cmd.exe and pass the ipconfig /release amd then another one with ipconfig / renew but this wont let you specify the ip address.
or you could just use shell and "netsh interface ip set address" ......