Most of the time will be using DHCP and sometimes a static IP depending on
where I am.
Would appreciate some help if someone has code that will work. I have been
told to make two .reg files one for DHCP and one for my static ip, it does
not work on Windows 2000. Also hardware profiles that will not work for
what I want to do. I just want to compile an app that has my preset IP
addresses. To reply to me remove ATHOME from my address.
Thanks,
Bob
No matter how you do it, switching between DHCP and static IP addresses is
basically a matter of changing registry entries. Loading a .reg file and
rebooting is the most straight-forward way of doing this, since very little of
the intimately connected OS info in the registry is incorporated without a
reboot.
Network info is read and processed before the GUI is started in other versions
of Windows (watch the network adapter lights during a DHCP boot). A "hot
switch" without rebooting may not be available.
VB3 source code: http://thelabwiz.home.mindspring.com/vbsource.html
VB6 source code: http://thelabwiz.home.mindspring.com/vb6source.html
VB6 - MySQL how to: http://thelabwiz.home.mindspring.com/mysql.html
Fix the obvious to reply by email.
I created textboxes in my app that addresses can be copied to and then
executed.
Bob
To Enable DHCP:
Enables the DHCP client service on a computer. The computer will then use
DHCP to obtain an IP address rather than use a static IP address.
Script Code
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Next
CHANGE TO STATIC IP
The sample scripts are not supported under any Microsoft standard support
program or service. You can, however, report issues and bugs by sending
e-mail to scri...@microsoft.com.
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcen
ter/network/Scrnet01.asp
Configuring a Static IP Address
Description
Sets the IP address of a computer to 192.168.1.141, and sets the IP gateway
to 192.168.1.100.
Script Code
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\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.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
Determining a Computer's IP Address
Description
Returns the IP address for each IP-enabled network adapter installed in a
computer.
Script Code
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _("Select IPAddress from
Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
The System Administration Scripting Guide, part of the Windows .NET Server
Resource Kit. For more information, contact scri...@microsoft.com.
BS
"Bob Schor" <bsc...@pitt.edu> wrote in message
news:3DA7401F...@pitt.edu...