I am trying to create an application which opens the Windows Explorer search function and searches for files/folders with the specified term entered. I have the code already for Windows Vista SP1+ (which uses the "search:query=") command introduced with Windows Indexing service. This does not work in Windows XP and so I am in search of a command/code (command line, batch script, c++, etc) that will open Windows Explorer in the "find file/folder" mode with the search term entered also (send from the application with the command). Thanks
Yes, there is a (really long) command that can do a search.
explorer.exe search-ms:displayname=Search Results (or put whatever title you want)&crumb=System.Generic.String%3A(search string)&crumb=location:(path)
Here's a breakdown of how it works:
If you run explorer.exe path, it will open the path you specify.
If you do a search and click on the icon used to show a path, it will show you a really long string of data. You can enter it as a path, and it will take you right back to the search.
In case you haven't figured it out, you can enter a command to take you to that path, therefore running a search.
With credit to,
http://www.somethingtoscrollthrough.com/2020/07/command-line-search-ms.html
for giving me the correct syntax, the following opens an Explorer Window on Windows 10 in search mode with the query,
PDF documents on D drive whose text contents contain ALL the words (Windows, macro, openoffice).
explorer.exe "search-ms:query=content:(Windows AND macro AND openoffice) name:.pdf&crumb=location:d:\&"

For an exact phrase, use this form (note the double double quotes ""),
explorer.exe "search-ms:query=content:""OOME Fourth Edition"" name:.pdf&crumb=location:d:\&"
Or at its most basic form, all PDF files on Drive D that start with A,
explorer.exe "search-ms:query=a*.pdf&crumb=location:d:\&"
For more ideas of what is possible consult MS' syntax reference here,
https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With