troubleshooting Question

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

Avatar of jqgoode
jqgoode asked on
VB ScriptScripting LanguagesVisual Basic Classic
3 Comments2 Solutions1157 ViewsLast Modified:
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 & " ]"
ASKER CERTIFIED SOLUTION
jqgoode

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros