I need to know how to set a static IP address using VB.
Also setting the Subnet Mask & Default Gateway aswell.
If it makes a difference, the Computer already has a static IP address which
needs changing, it is not using DHCP.
Many Thanks
Stephen
The only way I know of to change this is via WMI (Windows Management
Instrumentation). Here is a code segment to assign a static IP address to
your computer. If you are not using Windows 2000 or Windows Millennium then
you will have to install WMI on the Computer.
Dim Adapter As Object
Dim ipaddr As Variant
Dim subnet As Variant
Dim gateway As Variant
Dim DNS As Variant
Dim RetVal As Integer
Set Adapter = GetObject("winmgmts:Win32_NetworkAdapterConfiguration=0")
ipaddr = Array("199.60.71.155")
subnet = Array("255.255.255.0")
gateway = Array("199.69.71.1")
DNS = Array("199.67.38.7")
'Set your adapter to a static IP address
RetVal = Adapter.EnableStatic(ipaddr, subnet)
'Set your gateway
Adapter.setgateways (gateway)
'Set your DNS
Adapter.SetDnsServerSearchOrder (DNS)