Short VBS code - get a single specified instance of Win32_PnPEntity class or get
a default unnamed instance (singleton) of the class, using one single command GetObject
with exact path of the wmi object.
Get a specified instance of Win32_PnPEntity by a key, get a default unnamed instance (singleton) of the class or list instances of the class by wmi query using this c# sample code.
See in another language:
VBScript
,
VB.Net
.
ManagementScope
scope =
new
ManagementScope
(
"\\\\.\\ROOT\\cimv2"
);
ObjectQuery
query =
new
ObjectQuery
(
"SELECT * FROM Win32_PnPEntity Where DeviceID=\"ACPI\\\\PNP0C02\\\\1\""
);
ManagementObjectSearcher
searcher =
new
ManagementObjectSearcher
(scope, query);
ManagementObjectCollection
queryCollection = searcher.Get();
foreach
(
ManagementObject
m
in
queryCollection)
Console.WriteLine
("PNPDeviceID : {0}", m["PNPDeviceID"]);
Get a specified instance of Win32_PnPEntity by a key, get a default unnamed instance (singleton) of the class or list instances of the class by wmi query using this VB.Net sample code.