[英]How to tell if a network adapter is removable on Windows
How can I tell if a given network adapter retrieved through the Win32 GetAdaptersInfo() or GetAdaptersAddresses() functions is a removable one, like USB, SmartCard, etc?如何判断通过 Win32 GetAdaptersInfo()或GetAdaptersAddresses()函数检索到的给定网络适配器是否是可移动的,例如 USB、SmartCard 等?
The documentation for these functions does not seem to contain any means of getting that information, so I'm assuming I have to go ask Windows for each device I find whether it is removable in some way.这些功能的文档似乎不包含任何获取该信息的方法,所以我假设我必须 go 询问 Windows 对于我发现它是否以某种方式可移动的每个设备。
What would you suggest?你有什么建议?
If you think about it then all adapters are removable (eg PCI, USB, Virtual, etc) Even an in-built NIC can usually be disabled in the BIOS.如果您考虑一下,那么所有适配器都是可拆卸的(例如 PCI、USB、虚拟等)即使是内置的 NIC 通常也可以在 BIOS 中禁用。
What you really want to know is the 'interface type' of each adapter.您真正想知道的是每个适配器的“接口类型”。 This information can be found in caption property of the Win32_NetworkAdapterConfiguration Class.
此信息可在 Win32_NetworkAdapterConfiguration Class 的标题属性中找到。 You could use this (with other information from the class) to work out how each device is connected to the machine and if it is in use.
您可以使用它(以及课程中的其他信息)来确定每个设备如何连接到机器以及它是否正在使用中。
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT Caption, IPEnabled FROM Win32_NetworkAdapterConfiguration",,48)
For Each objItem in colItems
Wscript.Echo objItem.IPEnabled & " " & objItem.Caption
Next
Also, the Win32_NetworkAdapterConfiguration is very useful for the IPEnabled property as it lets you see if TCP/IP is bound and enabled on the adapter.此外,Win32_NetworkAdapterConfiguration 对于 IPEnabled 属性非常有用,因为它可以让您查看 TCP/IP 是否已在适配器上绑定和启用。
Here is an example output这是一个示例 output
False [00000001] 1394 Net Adapter
False [00000002] RAS Async Adapter
False [00000003] WAN Miniport (L2TP)
False [00000004] WAN Miniport (PPTP)
False [00000005] WAN Miniport (PPPOE)
False [00000006] Direct Parallel
False [00000007] WAN Miniport (IP)
False [00000008] Packet Scheduler Miniport
True [00000009] Wireless-B PCI Adapter
False [00000010] Packet Scheduler Miniport
False [00000011] Cisco AnyConnect VPN Virtual Miniport Adapter for Windows
False [00000012] Packet Scheduler Miniport
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.