2009-08-06 46 views
1

我正在嘗試創建一個簡單的WQL查詢,我只在服務器上返回裝入的驅動器。這些驅動器沒有與它們相關的驅動器號。在WQL服務器上返回裝入的驅動器

我嘗試以下sytnax,並沒有返回結果集:

SELECT * FROM Win32_Volume WHERE DriveLetter = "" 

這是在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... 
} 

回答

2

我需要改變我的WQL語句:

SELECT * FROM Win32_Volume WHERE DriveLetter IS NULL 
相關問題