how to delete all exclude folders in search indexer and revert it to default?

windows user 20 Reputation points
2025-10-01T09:03:19.2833333+00:00

i have a windows 11 pc(23h2) and i'm trying to delete exclude folders in search indexer.

there is so many excluded folders in list such as cloned github repo, node_modules.

also deleting one or more will crash settings and it's not removed. plz help.

Windows for home | Windows 11 | Settings
0 comments No comments
{count} votes

Answer accepted by question author
  1. Ramesh Srinivasan 173.9K Reputation points Volunteer Moderator
    2025-10-04T04:15:02.6333333+00:00

    Please see if resetting Windows Search using this batch file helps. → reset_wsearch.bat

    Download the file, right-click on it and choose "Run as administrator."

    Note: It also resets the search index.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Emmanuel Santana 34,225 Reputation points Independent Advisor
    2025-10-01T10:16:20.1766667+00:00

    Hello. Do you recall installing any third-party search tools or using registry cleaners in the past? That could explain why the exclusions became locked or corrupted.

    You can reset everything (exclusions, index database, config) back to default using this PowerShell script. It bypasses the broken GUI and directly clears both the index data and registry entries:

    # Stop Windows Search Service
    Stop-Service -Name WSearch
    
    # Delete the current search index database and configuration
    Remove-Item -Path "$env:ProgramData\Microsoft\Search\Data\Applications\Windows" -Recurse -Force
    Remove-Item -Path "$env:ProgramData\Microsoft\Search\Data\Temp" -Recurse -Force
    
    # Optional: Reset registry exclusions (set back to defaults)
    Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost" -Name "DefaultGatherPolicy" -ErrorAction SilentlyContinue
    Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths" -Recurse -Force -ErrorAction SilentlyContinue
    
    # Start Search Service
    Start-Service -Name WSearch
    

    This will fully wipe the Search Indexer state and restore clean defaults. After a reboot, Windows will begin reindexing only the standard folders. If any exclusions still reappear, it means they’re being pushed by a policy or a background process.

    Let me know what happens after running this.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.