1

我正在尝试创建一个简单的 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...
}
4

1 回答 1

2

我需要将我的 WQL 语句更改为:

SELECT * FROM Win32_Volume WHERE DriveLetter IS NULL
于 2009-08-07T00:22:56.037 回答