tags:

views:

103

answers:

1

I am trying create a simple WQL query where I only return mounted drives on a server. These are drives that do not have a drive letter associated with them.

I tried the following sytnax and it does not return a result set:

SELECT * FROM Win32_Volume WHERE DriveLetter = ""

Here is the complete code sample in C#:

string ManagementPath = string.Format(@"\\{0}\root\CIMV2", txtServerName.Text);
ConnectionOptions DriveConnOptions = new ConnectionOptions();
ObjectQuery oq = new ObjectQuery(@"SELECT * FROM Win32_Volume WHERE DriveLetter = """"");
ManagementScope Scope = new ManagementScope(ManagementPath, DriveConnOptions);
ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Scope, oq);
ManagementObjectCollection collection = Searcher.Get();
foreach (ManagementObject mo in collection)
{
    //do something...
}
A: 

I need to change my WQL statement to:

SELECT * FROM Win32_Volume WHERE DriveLetter IS NULL
Michael Kniskern