A batch script for searching in Windows indexed files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 183
Joined: 26 Oct 2012 06:40
Location: Saint Hilaire du Touvet, France

A batch script for searching in Windows indexed files

#1 Post by jfl » 06 Dec 2021 13:29

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. :)



Post Reply