I am using WMI to detect a number of items about a network adapter's state. Among the things I need to find out are (a) speed and (b) duplex.
I have been able to detect the speed of a network adapter by using WMI and the following Python code:
from pycom.client import wmi
dev_name = r"\\DEVICE\\{287EB4BB-5C2A-4108-B377-15E1D0B0E760}"
query1 = """
SELECT *
FROM MSNdis_EnumerateAdapter
WHERE DeviceName = '%s'""" % dev_name
wmi_ndis = wmi.WMI("root\\WMI")
results = wmi_ndis.ExecQuery(query1)
instance_name = results[0].InstanceName
del results
query2="""
SELECT *
FROM MSNdis_LinkSpeed
WHERE InstanceName='%s'""" % instance_name
results = wmi_ndis.ExecQuery(query2)
linkspeed = results[0].NdisLinkSpeed
del results
print instance_name, linkspeed
del instance_name
del linkspeed
del wmi_ndis
There appears to be a perfect class for the data I want: MSNDis_LinkParameters. However, this table does not appear to be populated. There are values in Win32_NetworkAdapter as well, but they are also not populated.
I would be happy to use a native C API or WMI, but I can't do screen scraping because the application needs to work with arbitrary languages. Thanks!