Discussion on:
DOWNLOAD: Toggle Windows XP Pro IP address settings with this VB script

14
Comments

Join the conversation!

Follow via:
RSS
Email Alert
Just In
just what i need
totalrecall@... 12th May 2007
good enough with mod happy
When troubleshooting IP connectivity problems on Windows XP Pro machines configured for DHCP, it's often handy to assign the computer a static IP address. This allows you to quickly determine if the problem is related to the DHCP server, local machine, or physical network connection. Yet, repeatedly changing the IP address from dynamic to static can be a hassle. Using our Windows XP Pro IP Address Toggle Tool, written by Greg Shultz, you can easily switch between dynamic and static addresses with the click of a button.

Download and try the tool:
http://techrepublic.com.com/5138-10877-5720432.html

Then, Join this ongoing discussion and let us know if you find the Windows XP Pro IP Address Toggle VB Script useful and if there's anything we can do to improve the tool.
0 Votes
+ -
Nothing
jbaker@... 24th May 2005
I get nothing....
0 Votes
+ -
Contributr
Feedback
Greg Shultz Updated - 26th May 2005
This was a challenging script to write due to the fact that I discovered that Windows XP considers several types of devices, besides the actual Ethernet NIC as network adapters.

The IP Toggle script contains logic to sort through all the devices considered as network adapters and pick out only those that are assigned IP addresses.

If your computer has several network adapters to which Windows XP is configured to assign IP addresses, then you'll see a prompt for each adapter.

If you see more than one prompt, please let me know the names of the devices that Windows XP considers network adapters on your system.
0 Votes
+ -
Like another member, I'm glad to learn a bit about netsh, but the script works great for me and I think it'll be handy (the crossover scenario is one case).

Just wanted you to know that I appreciate your work, Greg. Keep 'em coming. happy

I, too, would like the ability to select among a variety of IP addresses--and seeing the change (i.e., the settings that were affected) would be great.
0 Votes
+ -
not needed
jakesty 2nd Jun 2005
For me, the built in command "netsh" works on 2000 and XP, and it runs from the command line. When I troubleshoot or set up some computers, I usually do 50 or 100 systems. By using NETSH from the command line and combining that with the wonderful program called PSEXEC from SYSTERNALS.com, I was able to change all of the users in the network to DHCP and add a different subnet mask in a mere few minutes.

Click Start-Run-cmd then enter
type "netsh interface ip show config" without quotes.
You will see a nice display of your network settings.
Here is the bat file I used to update a workstations settings with a new subnet mask of 255.255.0.0

@echo off

FOR /F "TOKENS=2* DELIMS=:" %%A IN ('NETSH INTERFACE IP SHOW CONFIG ^| FIND "SubnetMask"') DO FOR %%B IN (%%A) DO SET SUBNETMASK=%%B
if SUBNETMASk=="255.255.0.0" then goto skip

FOR /F "TOKENS=2* DELIMS=:" %%A IN ('NETSH INTERFACE IP SHOW CONFIG ^| FIND "IP Address"') DO FOR %%B IN (%%A) DO SET IPADDR=%%B

SET SUBNETMASK=255.255.0.0

FOR /F "TOKENS=2* DELIMS=:" %%A IN ('NETSH INTERFACE IP SHOW CONFIG ^| FIND "Default Gateway"') DO FOR %%B IN (%%A) DO SET DEFGATEWAY=%%B

netsh interface ip show config

netsh interface ip set address "Local Area Connection" static %IPADDR% %SUBNETMASK% %DEFGATEWAY% 1
goto end

:SKIP

:END


Save this bat on the network, use PSEXEC and execute it across all of your pcs to make global changes.
The power of command-line and DOS is oftentimes just easier to do in a network.
Maybe I miss the original intent of your vb app, but I'm always reluctant to add more software to a computer for any reason.

Jake
I agree that you missed the point entirely.
However ...
The NETSH command is useful information.
Thank you.

I've given up on DHCP and assigned a static address to my laptop on my network.

When I go into the field to connect to a network printer with a cross-over cable to test the NIC,
I don't want to change any settings on the printer.

I want to match the IP & subnet of the printer to my laptop to troubleshoot it.
And I don't want to waste time rebooting and switching back & forth.

Ps: The vbs for XP runs on Win2K but errors out.
Do one for Windows 2000 and I'll consider switching back to DHCP.
0 Votes
+ -
I'm not a good scripter and was wondering if I could make a request. I could use this the way it is and just make multiple copies, but is there any whay it could prompt for the fourth octet of the static address. In other words there are times I need to swap between two differet static ip's.

Thanks
NETSH from the command line allows you make every possible change to one or more network adapters, save and restore your configuration, with a little .BAT you can do everything in IP4 and also IP6.
0 Votes
+ -
good enough with mod happy
0 Votes
+ -
I have wireless and cabel eathernet adapters on my notebook, I'v got following problem with them.

Script is doing: "For Each Item in NetAdapters
ask if user wants toggle it"
and then if "Yes" it runs:
"For Each Item in NetAdapters toggle",
so all adapters are toggled.

I allready fixed it for myself, sugest you else to do so. I just defined another constant with MAC adress of the adapter I want to swithc, don't like a lot of popups.
0 Votes
+ -
Networks where I run static and dynamic are completely different, I got else following bugs:

When switching to static IP It does not set defined DNS servers
It looks like
SetDNSServerSearchOrder() does not work with
argument DNSServers = Array("147.32.98.2","0.0.0.0")

But with DNSServers = Array("147.32.98.2") it does

Else when go dynamic I needed to add
Item.SetGateways("",Gatewaymetric)
which clears gateway record, and it is recieved then correctly from DHCP server
0 Votes
+ -
I find the toggle tool script to be very handy, as I use a laptop - static ip addressing at home and dhcp at school. However, I find it annoying that it puts up a prompt for every adapter on my computer. Is there any way to specify a single net adapter (ie my wireless card) to change ip addresses, rather than both my wireless and my ethernet cards?
I found your script very useful, except when there are multiple interfaces and one of them failed to initalize. Your loops set an "Enable" flag. This flage may or may not change during the loop, so your Verify function was producing inacruate results. Here I re-wrote the ChangeIPAddress sub-routine:

Sub ChangeIPAddress

For Each Item in NetAdapters

If Item.DHCPEnabled then
ChangeIt = MsgBox("For this network Adapter: " & Item.Description & vbCrLf & vbCrLf & "Windows XP is currently set to use: Dynamic IP Addressing " & vbCrLf & vbCrLf & "Do you want to change it to: Static IP Addressing ",36,"IP Address Toggle Tool")
If ChangeIt = vbYes Then
' Make it Static
Dummy = WshShell.Popup("Please wait...", 2, "IP Address Toggle Tool", 48)
Enable = Item.EnableStatic(IPAddress, SubnetMask)
Gateways = Item.SetGateways(Gateway, Gatewaymetric)
TheDNS = Item.SetDNSServerSearchOrder(DNSServers)
End If
Else
ChangeIt = MsgBox("For this network Adapter: " & Item.Description & vbCrLf & vbCrLf & "Windows XP is currently set to use: Static IP Addressing " & vbCrLf & vbCrLf & "Do you want to change it to: Dynamic IP Addressing ",36,"IP Address Toggle Tool")
If ChangeIt = vbYes Then
' Make it Dynamic
Dummy = WshShell.Popup("Please wait...", 2, "IP Address Toggle Tool", 48)
Enable = Item.EnableDHCP()
TheDNS = Item.SetDNSServerSearchOrder()
End If
End If
If Enable 0 Then
Dummy = MsgBox("The IP address could not be changed.", 16, "IP Address Toggle Tool")
End If

Next

End Sub 'ChangeIPAddress
0 Votes
+ -
First of, you have to reboot a computer after running this script to make the Static IP "stick" on the system. You can see the changes before rebooting, and everything looks OK, but I was not able to connect to other network devices until I rebooted. I prefer not to reboot too often.

Also, when changing back to DHCP/Dynamic the Gateway IP from the static settings is still present (if you do an IPconfig /all in a DOS prompt). this can of course cause unwanted results.

Thanks,

SF
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.