Link to home
Create AccountLog in
Avatar of jqgoode
jqgoode

asked on

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

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

Avatar of chandru_sol
chandru_sol
Flag of India image

Hi,

Attached script will give you all the IP address for the interfaces

I have show the reports in a message box, let me know what changes you need

regards
Chandru
strcomputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
 
for each objitem in colitems
 
strIPAddress = Join(objitem.IPAddress, ",")
         IP = stripaddress
wscript.echo ip
 
Next

Open in new window

SOLUTION
Avatar of chandru_sol
chandru_sol
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.