在 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...
}
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...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我需要将 WQL 语句更改为:
I need to change my WQL statement to: