Hi,
I wrote some basic code in C# like so:
//Connection credentials to the remote computer - not needed if the logged in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "";
oConn.Password = "";
System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\MachineX", oConn);
//get Fixed disk stats
System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");
//Execute the query
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs,oQuery);
//Get the results
ManagementObjectCollection oReturnCollection = oSearcher.Get();
//loop through found drives and write out info
foreach( ManagementObject oReturn in oReturnCollection )
{
// Disk name
Console.WriteLine("Name : " + oReturn["Name"].ToString());
// Free Space in bytes
Console.WriteLine("FreeSpace: " + oReturn["FreeSpace"].ToString());
// Size in bytes
Console.WriteLine("Size: " + oReturn["Size"].ToString());
}
Where the username and password are provided as the credentials for my local desktop account.
When I get to the line where the ManagementObjectCollection type is returned from the ManagementObjectSearcher Get() method, I get an error (at runtime) saying function call timed out when I try to evaluate this line (last line before the foreach loop).
There is no exception so no more details on the error.
How can I fix this? The code looks fine to me? This code is on another machine so I am using the code from here (pretty much follows the same steps): http://www.csharphelp.com/archives2/archive334.html
Thanks