Skip to content

Instantly share code, notes, and snippets.

@tbbooher
Last active March 9, 2026 00:09
Show Gist options
  • Select an option

  • Save tbbooher/8ffbeb52a87a5315fc12e51266f96e7d to your computer and use it in GitHub Desktop.

Select an option

Save tbbooher/8ffbeb52a87a5315fc12e51266f96e7d to your computer and use it in GitHub Desktop.
Run this script to make windows just search files.
#Requires -RunAsAdministrator
$ErrorActionPreference = "Stop"
function Set-DwordPolicy {
param(
[Parameter(Mandatory = $true)][string]$Path,
[Parameter(Mandatory = $true)][string]$Name,
[Parameter(Mandatory = $true)][int]$Value
)
if (-not (Test-Path $Path)) {
New-Item -Path $Path -Force | Out-Null
}
New-ItemProperty -Path $Path -Name $Name -PropertyType DWord -Value $Value -Force | Out-Null
}
Write-Host "Applying Windows cleanup policies..." -ForegroundColor Cyan
# -----------------------------
# 1) WIDGETS OFF
# -----------------------------
# Microsoft-documented policy keys:
# HKLM\SOFTWARE\Policies\Microsoft\Dsh
# AllowNewsAndInterests = 0 -> Widgets not allowed
# DisableWidgetsBoard = 1 -> Widgets board disabled
# DisableWidgetsOnLockScreen = 1 -> No lock screen widgets
$widgetsPath = "HKLM:\SOFTWARE\Policies\Microsoft\Dsh"
Set-DwordPolicy -Path $widgetsPath -Name "AllowNewsAndInterests" -Value 0
Set-DwordPolicy -Path $widgetsPath -Name "DisableWidgetsBoard" -Value 1
Set-DwordPolicy -Path $widgetsPath -Name "DisableWidgetsOnLockScreen" -Value 1
# -----------------------------
# 2) SEARCH CLEAN, BUT STILL WORKING
# -----------------------------
# Microsoft-documented policy keys:
# HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search
# EnableDynamicContentInWSB = 0 -> Search highlights off
# DisableSearch = 0 -> Search UI stays enabled
$searchPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
Set-DwordPolicy -Path $searchPath -Name "EnableDynamicContentInWSB" -Value 0
Set-DwordPolicy -Path $searchPath -Name "DisableSearch" -Value 0
# Optional cleanup: if a previous script left bad values behind, remove and re-set cleanly
# Remove-ItemProperty -Path $searchPath -Name "DisableSearch" -ErrorAction SilentlyContinue
# Set-DwordPolicy -Path $searchPath -Name "DisableSearch" -Value 0
Write-Host "Restarting Explorer and Search processes..." -ForegroundColor Cyan
# Restart Explorer so taskbar/UI refresh immediately
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue
Start-Process explorer.exe
# Restart Search-related processes if present
Stop-Process -Name SearchHost -Force -ErrorAction SilentlyContinue
Stop-Process -Name SearchApp -Force -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "Done." -ForegroundColor Green
Write-Host "Widgets are off, Widgets Board is off, lock screen widgets are off," -ForegroundColor Green
Write-Host "and Search highlights are off while normal Search remains enabled." -ForegroundColor Green
Write-Host ""
Write-Host "If any visual element lingers, sign out and back in once." -ForegroundColor Yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment