我正在尝试创建一个简单的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...
}
答案 0 :(得分:2)
我需要将我的WQL语句更改为:
SELECT * FROM Win32_Volume WHERE DriveLetter IS NULL