a guest Jan 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- ConnectionOptions oConn = new ConnectionOptions();
- oConn.Username = "username";
- oConn.Password = "password";
- oConn.Authority = "ntlmdomain:XXX";
- ManagementScope scope = new ManagementScope("\\Remote_Computer\root\CIMV2", oConn);
- ObjectQuery query = new ObjectQuery("SELECT DeviceID, VolumeName FROM Win32_LogicalDisk where DeviceID = 'D:'");
- ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
- ManagementObjectCollection queryCollection = searcher.Get();
- foreach (ManagementObject m in queryCollection)
- //error happens here
- fs = m["FreeSpace"].ToString();
- freeSpace = Convert.ToInt64(fs);
- "SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID = 'D:'"
RAW Paste Data