A
ak268
Guest
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().
I am trying to get the free disk space on a remote PC. I have tried using the string
select Size from Win32_LogicalDisk where DriveType=3
but get an error "User credentials cannot be used for local connections"
This is my code:
//Connection credentials to the remote computer - not needed if the logged in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "Administrator";
oConn.Password = "pass";
System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\192.168.0.106", oConn);
//get Fixed disk stats
System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select Size from Win32_LogicalDisk where DriveType=3");
//Execute the query
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
//Get the results
ManagementObjectCollection oReturnCollection = oSearcher.Get();
I thought that perhpas the string i am passing in to ObjectQuery is incorrect.
Any ideas?
Thanks in advance.
ak268
Continue reading...
I am trying to get the free disk space on a remote PC. I have tried using the string
select Size from Win32_LogicalDisk where DriveType=3
but get an error "User credentials cannot be used for local connections"
This is my code:
//Connection credentials to the remote computer - not needed if the logged in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "Administrator";
oConn.Password = "pass";
System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\192.168.0.106", oConn);
//get Fixed disk stats
System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select Size from Win32_LogicalDisk where DriveType=3");
//Execute the query
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
//Get the results
ManagementObjectCollection oReturnCollection = oSearcher.Get();
I thought that perhpas the string i am passing in to ObjectQuery is incorrect.
Any ideas?
Thanks in advance.
ak268
Continue reading...