We help IT Professionals succeed at work.
Get Started

Need VBscipt to pull IP Address from both Wireless card AND Wired interface in XP PC

1,156 Views
Last Modified: 2012-05-05
Hi,

I need a VBscript that is able to pull the IP address from both a  Wired and wireless connection. on a XP workstation  If a person is connected to both, I need those IP address.   If I find one, then that becomes the IP address . If I do not find either, I want to exit

I have something that will work for just the LAN interface - attached

Any ideas?
Dim Strcomputer, strIPAddress
 
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
 
Set colItems = objWMIService.ExecQuery _
	("Select IPAddress From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
	
	'Go through the IP addresses
	For Each IPAddress In colItems
		If IPAddress.IPaddress(0) <> "0.0.0.0" Then
			strIPAddress = IPAddress.IPAddress(0)
			Exit For
		Else
			Sendmessage "Info", "The computer is not connected to the  Network" & vbNewLine &_
			"Please attach to a connection on the Network and Rerun the program"
			WScript.Quit
		End If
	Next
	Wscript.echo "The IP Address Is " & "[ " & strIPAddress & " ]"

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE