Guest User

Untitled

a guest
May 16th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. WMI Search Wildcard returns nothing
  2. ManagementScope oScope = new ManagementScope("\\" + txtHostName +
  3. "\root\CIMV2", oConn);
  4.  
  5. string wheresub = "FileName Like '%myfile%'";
  6.  
  7. ObjectQuery oQuery = new ObjectQuery(@"SELECT * FROM CIM_DataFile WHERE (" +
  8. wheresub + ") AND (Drive = 'C:' OR Drive = 'D:' OR Drive = 'E:')");
  9.  
  10. ManagementObjectSearcher searcher = new ManagementObjectSearcher(oScope, oQuery);
  11.  
  12. Log("Searching...");
  13.  
  14. foreach (ManagementObject queryObj in searcher.Get())
  15. {
  16. FilesFound++;
  17. Log(String.Format("--> {0}{1}{2}.{3}", queryObj["Drive"], queryObj["Path"], queryObj["FileName"], queryObj["Extension"]));
  18. }
  19. if (FilesFound > 0)
  20. {
  21. Log(" " + FilesFound + " files found.");
  22. }
  23. else
  24. {
  25. Log(" Clean.");
  26. }
  27.  
  28. string wheresub = "FileName = 'PROCID_myfile_1234'";
Advertisement
Add Comment
Please, Sign In to add comment