Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WMI Search Wildcard returns nothing
- ManagementScope oScope = new ManagementScope("\\" + txtHostName +
- "\root\CIMV2", oConn);
- string wheresub = "FileName Like '%myfile%'";
- ObjectQuery oQuery = new ObjectQuery(@"SELECT * FROM CIM_DataFile WHERE (" +
- wheresub + ") AND (Drive = 'C:' OR Drive = 'D:' OR Drive = 'E:')");
- ManagementObjectSearcher searcher = new ManagementObjectSearcher(oScope, oQuery);
- Log("Searching...");
- foreach (ManagementObject queryObj in searcher.Get())
- {
- FilesFound++;
- Log(String.Format("--> {0}{1}{2}.{3}", queryObj["Drive"], queryObj["Path"], queryObj["FileName"], queryObj["Extension"]));
- }
- if (FilesFound > 0)
- {
- Log(" " + FilesFound + " files found.");
- }
- else
- {
- Log(" Clean.");
- }
- string wheresub = "FileName = 'PROCID_myfile_1234'";
Advertisement
Add Comment
Please, Sign In to add comment