michael orlitzky

Windows file search is broken

Broken. As in, when you tell it to search through some files, it will not search through those files. Worse, it won't even mention that it completely ignored you.


Let's say you're getting ready to remove a database from production (if you can't tell, this is in no way a hypothetical situation). You think that it's been phased out and that no code is accessing the database anymore. To be sure, you'd want to search through all of your application code for occurrences of the database name.

Let's say the database is called important-db. You would tell Windows search to check all sub-folders of C:\application_root (or whatever) for files containing the text “important-db”. If the search came back with no results, it'd be safe to remove the database, right?


the fuck

It turns out, there is one slightly important catch. Windows maintains a secret list of magical files and extensions that it will refuse to search, even if you explicitly state that you would like to search them. ASP files are included in this magic list.

I humbly refer the reader to KB 309173 should he or she wish to know what this list contains.

The most interesting part of the article is that, for each file type, a “filter provider” is defined in the registry. This filter is what decides how to search the file type for some text. So, given a file type, some stupid registry entry will decide whether or not text search will behave how you think it will. For example, HTML comments (within HTML files) will not be searched. Haha! Fuck you.

how to fix this garbage

Boot to Debian Linux, and use grep. Seriously. Seriously.

Ok. To fix it under Windows, you get to manually edit the registry. The premise is that the plain text (.txt) filter acts like you'd expect it to. If you would like a particular file type's filter to act sane, you should switch its filter to the plain text filter. This is all in the KB article.

To do this, add a PersistentHandler key under the file type key in HKEY_CLASSES_ROOT and set its (Default) string value name to the following value:


For example, to use the text filter provider for .asp files, the following registry setting should exist:

HKEY_CLASSES_ROOT\.asp\PersistentHandler\(Default) = {5e941d80-bf96-11cd-b579-08002b30bfeb}

After you add this value to the registry, you must log off and then log back on to make the change take effect.