Windows Repair Commands Reference
Copy-paste ready commands for diagnosing and repairing Windows problems. Each command includes syntax, flags, when to use it, and links to related troubleshooting guides.
System File Checker
Requires AdminScans all protected system files and replaces corrupted copies with cached originals from the component store.
# Run as Administrator
sfc /scannowCommon Flags
/scannowScan and repair all protected system files immediately/verifyonlyScan but do not repair (report only)/scanfile=<path>Scan and repair a specific fileWhat It Does
SFC checks every Windows system file against its known-good copy in the WinSxS component store. If a file is missing or corrupted, SFC replaces it. Results are logged to CBS.log.
When to Use
Run after blue screens, app crashes, explorer crashing, or any symptom suggesting corrupted system files. Always run DISM first to ensure the component store is healthy.
Deployment Image Servicing and Management
Requires AdminRepairs the Windows component store by downloading fresh copies of corrupted components from Windows Update.
# Run as Administrator
DISM /Online /Cleanup-Image /RestoreHealthCommon Flags
/RestoreHealthScan and repair component store corruption/CheckHealthQuick check if corruption is detected (no repair)/ScanHealthDeep scan for corruption (no repair)/Source:<path>Use a local source (ISO/WIM) instead of Windows Update/Cleanup-Image /StartComponentCleanupRemove superseded components to free disk spaceWhat It Does
DISM services the Windows image. /RestoreHealth downloads fresh copies of any corrupted component store files from Windows Update. This must succeed before SFC can repair system files.
When to Use
Run before SFC /scannow. Essential when SFC reports it found corruption but could not fix it. Also fixes Windows Update failures caused by component store damage.
Check Disk
Requires AdminScans the file system for errors and bad sectors. Repairs logical file system issues and marks bad physical sectors.
# Run as Administrator
chkdsk C: /f /rCommon Flags
/fFix file system errors/rLocate bad sectors and recover readable data (implies /f)/xForce volume dismount before scan/bRe-evaluate bad clusters on the volume (NTFS only, implies /r)What It Does
CHKDSK verifies the file system integrity of a volume. /f fixes logical errors (cross-linked files, orphan entries). /r scans the physical disk surface for bad sectors. On the system drive, it schedules a scan at next reboot.
When to Use
Run when you experience 100% disk usage, file access errors, blue screens with disk-related stop codes, or after unexpected shutdowns.
Winsock Reset
Requires AdminResets the Winsock catalog to its default state, fixing network connectivity issues caused by corrupted socket entries.
# Run as Administrator
netsh winsock resetCommon Flags
winsock resetReset the Winsock catalog to defaultint ip resetReset TCP/IP stack (often run together with winsock reset)advfirewall resetReset Windows Firewall to defaultsWhat It Does
Rebuilds the Winsock catalog — the interface between Windows apps and the TCP/IP protocol stack. A corrupted Winsock catalog causes "connected but no internet," DNS failures, and apps unable to reach the network.
When to Use
Run when you have WiFi connected but no internet, DNS not responding, or applications showing network errors while the connection appears active. Requires a restart to take effect.
Flush DNS Cache
Clears the local DNS resolver cache, forcing Windows to re-query DNS servers for all domain names.
ipconfig /flushdnsCommon Flags
/flushdnsClear the DNS resolver cache/releaseRelease the current DHCP lease/renewRenew the DHCP lease (get new IP)/displaydnsShow the contents of the DNS cache/registerdnsRefresh all DHCP leases and re-register DNS namesWhat It Does
Purges all cached DNS entries from the local resolver. This fixes issues where DNS records have changed but your PC still uses the old cached address. Often resolves "site not loading" issues when other sites work fine.
When to Use
Run when specific websites won't load, after changing DNS servers, or after network troubleshooting. Fast and safe — no restart required.
Boot Configuration Data Editor
Requires AdminViews and modifies the Boot Configuration Data (BCD) store that controls how Windows boots.
# Run as Administrator
bcdedit /enumCommon Flags
/enumList all boot entries/set {default} safeboot minimalForce next boot into Safe Mode/deletevalue {default} safebootRemove Safe Mode boot flag (boot normally)/set {default} recoveryenabled NoDisable Automatic Repair (escape repair loop)What It Does
BCD Editor manages the boot configuration database that replaced boot.ini. It controls which OS boots, boot parameters, Safe Mode flags, and recovery options. Incorrect edits can prevent Windows from booting.
When to Use
Use to enter/exit Safe Mode, disable Automatic Repair loops, manage dual-boot configurations, or diagnose boot failures.
Windows Recovery Agent
Requires AdminManages the Windows Recovery Environment (WinRE) — enables, disables, or reports on recovery partition status.
# Run as Administrator
reagentc /infoCommon Flags
/infoDisplay WinRE configuration and status/enableEnable the Windows Recovery Environment/disableDisable WinRE (required before partition changes)/setreimage /path <dir>Set location of the WinRE imageWhat It Does
ReAgentC manages the Windows Recovery Environment that powers "Reset this PC," Startup Repair, and the Advanced Startup Options menu. If WinRE is disabled or its partition is missing, recovery features won't work.
When to Use
Run when "Reset this PC" fails, when the recovery environment is missing, or before modifying disk partitions that might affect the recovery partition.
Boot Record Repair
Requires AdminRebuilds the Boot Configuration Data store from scratch. Used in the Windows Recovery Environment to fix boot failures.
# Run as Administrator
bootrec /rebuildbcdCommon Flags
/fixmbrWrite a new Master Boot Record to the system partition/fixbootWrite a new boot sector to the system partition/rebuildbcdScan all disks and rebuild the BCD store/scanosScan disks for Windows installations not in BCDWhat It Does
Bootrec runs from the Windows Recovery Environment (not from a running Windows). It repairs the Master Boot Record, boot sector, and BCD store. This is the primary tool for fixing "no bootable device" and missing OS errors.
When to Use
Use when Windows won't boot at all — "no operating system found," boot device errors, or after disk/partition changes that broke the boot configuration. Must be run from WinRE or a USB recovery drive.
Windows Update Service Control
Requires AdminStops the Windows Update service. Used as part of the Windows Update reset procedure to clear corrupted update cache.
# Run as Administrator
net stop wuauserv && net stop bits && net stop cryptsvcCommon Flags
net stop wuauservStop Windows Update servicenet stop bitsStop Background Intelligent Transfer Servicenet stop cryptsvcStop Cryptographic Servicesnet start wuauservStart Windows Update serviceWhat It Does
Stops the Windows Update service chain so you can rename or delete the SoftwareDistribution folder (update cache). After clearing the cache and restarting services, Windows Update rebuilds from scratch.
When to Use
Use when Windows Update is stuck, failing with error codes, or downloading the same update repeatedly. This is the standard "reset Windows Update" procedure.
Microsoft Store Cache Reset
Clears the Microsoft Store cache without removing app data or sign-in state.
wsreset.exeWhat It Does
Resets the Microsoft Store app cache. This fixes Store app download failures, stuck downloads, and authentication issues without uninstalling any apps. A Store window opens automatically when the reset completes.
When to Use
Run when the Microsoft Store won't open, downloads are stuck at "Pending," or Store apps fail to update.
Re-register All Store Apps (PowerShell)
Requires AdminRe-registers all UWP/Store apps, fixing broken app packages without losing data.
# Run as Administrator
Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -Register "$($_.InstallLocation)\AppxManifest.xml" -DisableDevelopmentMode}What It Does
Iterates through every installed Store app package and re-registers it with the system. This repairs broken app manifests, missing Start Menu tiles, and apps that crash on launch without deleting app data.
When to Use
Use when multiple Store apps are broken simultaneously, Start Menu tiles are blank, or after a Windows update that broke UWP apps. Also effective for individual apps by filtering with -Name "*AppName*".
Battery Health Report
Requires AdminGenerates a detailed HTML battery health report showing capacity history, usage patterns, and battery degradation over time.
# Run as Administrator
powercfg /batteryreport /output C:\battery-report.htmlCommon Flags
/batteryreportGenerate battery health report/energyGenerate energy efficiency report (identifies power drains)/sleepstudyAnalyze modern standby activity/requestsShow active power requests preventing sleepWhat It Does
Creates a detailed HTML report showing battery design capacity vs. current full charge capacity, charge/discharge cycles, usage history, and estimated battery life. The /energy flag identifies system components preventing efficient power management.
When to Use
Run when battery drains fast, laptop won't sleep properly, or to check battery health/degradation. The /requests flag identifies processes preventing sleep.