21

Search Indexing is interfering with our build process, and I would like to exclude all instances of our dev directories from the indexer (we have a trunk and branches setup).
I could exclude the whole parent directory, but that would exclude too many files.

I can do it manually by deselecting each instance in the indexing options, but this is very manual and tedious.

I've found the rules in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules, but I don't know if it's kosher to update that on the fly.

Is it possible to exclude directories from Windows Search by wildcard or some other less-manual criteria?

4
  • 1
    My best advice is to ditch the defective Windows Search and use third-party products. For search : Everything Search Engine and Agent Ransack. For the Start menu : Classic Shell.
    – harrymc
    Sep 18, 2016 at 8:45
  • @harrymc Nice suggestions! I actually use Everything search myself, but Windows search indexing is still an integral part of Windows. Disabling it entirely stops some other functions, for example without it OneNote search or even tagging doesn't work. Excluding directories would've just been a way to keep it from doing unnecessary work. Sep 22, 2016 at 10:38
  • Windows Search is what it is and there is a limit to its flexibility. You might limit its range to the absolute minimum that you need, and use the above utilities for the heavy work.
    – harrymc
    Sep 22, 2016 at 19:35
  • Possible duplicate of windows 7 how do I search for files and exclude subfolders?
    – Ramhound
    May 5, 2019 at 22:50

1 Answer 1

24

I looked in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules key and found something interesting.

DefaultRules\1 contains:

Default   REG_DWORD    0x00000001
Include   REG_DWORD    0x00000000
Policy    REG_DWORD    0x00000000
Suppress  REG_DWORD    0x00000000
URL       REG_SZ       file:///C:\Users\*\AppData\Local\Temp\*

Look at that URL key - two wildcards!

So since Windows Search natively supports wildcards, all we have to do is tweak an existing exception.

Adding wildcard exceptions to Windows Search

  1. Add template exception.
    Add an exception for a suitable directory by going to Indexing OptionsModify and deselecting one directory (in my case, C:\Users\MyName\dev\trunk\bin).
  2. Stop the Windows Search service.
    Go to Services, select Windows Search, right-click on it, and select Stop.
  3. Find the existing exception.
    Open Registry Editor and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules.
    Look through each numbered subkey to find yours.
  4. Tweak the exception.
    In my case, I have multiple branches checked out, so I will have directories for trunk and for each versioned branch (such as 3.2, 4.0, etc). So I changed the URL key from

    file:///C:\Users\MyName\dev\ProjectName\trunk\bin
    

    to

    file:///C:\Users\MyName\dev\ProjectName\*\bin
    
  5. Restart the Windows Search service.
    Right-click on Windows Search and select Start or Restart.

That's it! The directories are even unchecked/excluded in the Indexing Options.

8
  • 1
    Note that you will need to delete and rebuild your index (or delete and recreate the previously-indexed files) to prevent Windows Search from continuing to monitor those locations.
    – mskfisher
    Apr 8, 2011 at 15:59
  • 1
    My exceptions showed up in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules`
    – CAD bloke
    Jan 15, 2015 at 9:58
  • 6
    Has anyone been able to confirm whether or not the wildcard spans multiple directories? Say I wanted to prevent indexing all folders named 'node_modules' no matter where they are in the file hierarchy?
    – M-Pixel
    Dec 5, 2015 at 5:49
  • 1
    @Qwertman You should be able to verify that by looking at it in the Indexing Options UI.
    – mskfisher
    Dec 5, 2015 at 17:44
  • 2
    Windows 10 gives Error Editing Value Cannot edit URL: Error writing the value's new contents. Edit: Ahhh just needed to change permissions on the key Sep 18, 2016 at 3:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .