开发者

Search For Win32_Directory using the Volume Guid

I am trying to check if a directory exists on a remote computer by using the Volume GUID rather than the Volume Name. Is there any way in WMI to accomplish this? I have a tried a few different approaches but my WQL syntax never seems to be correct, most likely becuase of poor character escaping. Below is one of my attempts at the problem:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
     class Program
     {
         static void Main(string[] args)
         {
                ObjectQuery query = new ObjectQuery("Select * From Win32_Directory Where Name=\"" + @"\\\\?\\Volume{10b4259b-f659-11df-b8cc-806e6f6e6963}\\test" + "\"");

                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
                ManagementObjectCollection coll = sear开发者_如何学JAVAcher.Get();
                foreach (ManagementObject mo in coll)
                {
                    Console.Write("found");
                }
                 Console.Read();
         }
     }
}

When I execute this code, I receieve an Invalid Query exception. I have tried numerous Powershell attempts at this query and have received the same Invalid Query exception as well. Has anyone attempted this in the past or is it even possible?

Thanks, Chris

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜