WMI basic sample throws exception

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to start using WMI with C#, but the simplest sample from MSDN throws exception during run. The sample is below, the problem is <span style="font-size:x-small <font size="2 searcher.Get() </font> <span style="font-size:small throws exception "Not found". Any clues? <span style="font-size:x-small; color:#0000ff <font size="2" color="#0000ff class </font> <span style="font-size:x-small <span style="font-size:x-small; color:#008080 Query_SelectQuery<br/><span style="font-size:x-small {<br/><span style="font-size:x-small; color:#0000ff public<span style="font-size:x-small <span style="font-size:x-small; color:#0000ff static<span style="font-size:x-small <span style="font-size:x-small; color:#0000ff int<span style="font-size:x-small Main(<span style="font-size:x-small; color:#0000ff string<span style="font-size:x-small [] args)<br/>{<br/><span style="font-size:x-small; color:#008080 WqlObjectQuery<span style="font-size:x-small wqlQuery =<span style="font-size:x-small; color:#0000ff new<span style="font-size:x-small <span style="font-size:x-small; color:#008080 WqlObjectQuery<span style="font-size:x-small (<span style="font-size:x-small; color:#800000 "SELECT * FROM Win32_LogicalDisk"<span style="font-size:x-small );<br/><span style="font-size:x-small; color:#008080 ManagementObjectSearcher<span style="font-size:x-small searcher =<span style="font-size:x-small; color:#0000ff new<span style="font-size:x-small <span style="font-size:x-small; color:#008080 ManagementObjectSearcher<span style="font-size:x-small (wqlQuery); <span style="font-size:x-small; color:#0000ff <font size="2" color="#0000ff foreach </font> <span style="font-size:x-small (<span style="font-size:x-small; color:#008080 ManagementObject<span style="font-size:x-small disk<span style="font-size:x-small; color:#0000ff in<span style="font-size:x-small searcher.Get())<br/>{ <span style="font-size:x-small; color:#008080 <font size="2" color="#008080 Console </font> <span style="font-size:x-small .WriteLine(disk.ToString());<br/>}<br/>}<br/>}

View the full article
 
Back
Top