WMI System.Management.ObjectQuery valid strings and error "User credentials cannot be used for local

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im new to WMI and was wondering if anybody knows if there is a reference detailing the valid query strings that can be passed in to ObjectQuery().<br/> <br/> I am trying to get the free disk space on a remote PC. I have tried using the string<br/> <br/> select Size from Win32_LogicalDisk where DriveType=3<br/> <br/> but get an error "User credentials cannot be used for local connections"<br/> <br/> This is my code:<br/> <br/>                 //Connection credentials to the remote computer - not needed if the logged in account has access<br/>                 ConnectionOptions oConn = new ConnectionOptions();<br/>                 oConn.Username = "Administrator";<br/>                 oConn.Password = "pass";<br/> <br/>                 System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\192.168.0.106", oConn);<br/> <br/>                 //get Fixed disk stats<br/>                 System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select Size from Win32_LogicalDisk where DriveType=3");<br/> <br/>                 //Execute the query <br/>                 ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);<br/> <br/>                 //Get the results<br/>                 ManagementObjectCollection oReturnCollection = oSearcher.Get();<br/> <br/> I thought that perhpas the string i am passing in to ObjectQuery is incorrect.<br/> <br/> Any ideas? <br/> Thanks in advance.<br/> ak268

View the full article
 
Back
Top