Page 1 of 1

A batch script for searching in Windows indexed files

Posted: 06 Dec 2021 13:29
by jfl
The Windows 7 Start Menu had one feature I could not live without: The ability to search for local files with multiple criteria.
In Microsoft terms, this is querying the Windows Search service, using their Advanced Query Syntax.

Windows 10 extended its Start Menu to search on the Internet... But lost the local search advanced query capability in the process. :(
This did not bother me too much until now, because I was using OpenShell to get a Windows-7-like start menu in Windows 10, and OpenShell had a Windows-7-like search box. (Which proves that Windows 10 could do it, it's just that it's not implemented in their Start Menu search box.)

Last month I upgraded my laptop to Windows 11... And, catastrophy, the OpenShell search box does not work anymore :cry:
When doing a search, Windows Explorer pops up as before for showing the results... and closes immediately!

Determined to get my beloved feature back, I investigated how to program such searches.
And, pleasant surprise, one of the possibilities is to compose an ad-hoc URL, and pass it on to Windows Explorer.
Which reminded me that I had actually tried that when Windows 10 came out, and gave up for lack of time.
I dug up the script I had done then; Fixed what needed to be fixed; Et voilĂ , here's search.bat!

Example of use, run...

Code: Select all

search jupiter OR saturn
... and it'll a open a Windows Explorer instance, with a list of all the indexed files that contain either string.

To get help about the options, and a few basic AQS examples, run:

Code: Select all

search -?
There's even one improvement versus OpenShell's search box:
OpenShell always reused the same Explorer window.
search.bat opens a new window for each search, allowing to keep previous results if desired.

Still, there are a few things I'd like to improve, that I need help with:
  • Windows Explorer opens in "Content" view mode. I'd like to open it directly in "Details" view mode, to make it easier to sort differently the files listed.
    (I know this is feasible, because OpenShell did it!)
  • I'd like to automatically add other columns, first and foremost the search relevance factor, allowing to sort back by relevance if desired.
Any suggestion about the above, or any other possible improvement, are welcome. :)