Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI & NetConnectionID 1

Status
Not open for further replies.

sn0rg

IS-IT--Management
Joined
Aug 5, 2005
Messages
95
Location
GB
I've got a peice of code to enumerate the MAC addresses and connection names of network cards.

Where a network connection name is not present, I want to set the string to some valid data (ie "Not present").

However, when I use the following code, I can't trap the empty data. Can anyone help?

Code:
		Set colNICs =  objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where AdapterType = 'Ethernet 802.3'")

		For Each objAdapter in colNICs
			strSystemName = objAdapter.SystemName

			strMac = objAdapter.MacAddress

				If objAdapter.NetConnectionID = "" then
					strNetCon = "Not present"
				Else
					strNetCon = objAdapter.NetConnectionID
				End if

			strInner = strInner & "<td>" & strSystemName & "</td><td>" & strMac & "</td><td>" & strNetCon & "</td><tr>"
			objExplorer.Document.Body.InnerHTML = strInner
		Next
 
what part of the code doesnt work?
 
You may try this:
If Trim(objAdapter.NetConnectionID & "") = "" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Bingo PHV! Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top