Windows repair commands: sfc /scannow, DISM, chkdsk and more
The official Windows commands to repair system files, the drive, Windows Update, the internet connection and startup. Pick your problem, copy the command with one click and see what it does before you run it.
As administrator: right-click the Start button › Terminal (Admin), or search for «cmd» › right-click › Run as administrator. Paste the command with a right-click or Ctrl + V and press Enter.
-
Windows errors
Repair the Windows image (DISM)
DISM /Online /Cleanup-Image /RestoreHealth
Where: Command Prompt or Terminal as administrator.
Repairs the Windows component store by downloading healthy files from Windows Update. Run it before sfc, because sfc uses that store to repair files.
It takes several minutes and can sit at the same percentage for a long time: that is normal. It needs an internet connection.
-
Windows errors
Repair system files (sfc /scannow)
sfc /scannow
Where: Command Prompt or Terminal as administrator.
Checks every protected Windows file and replaces damaged ones with a healthy copy. It is the first step for odd errors, programs that will not open or blue screens.
Do not close the window until it reaches 100%. If it says it found files it could not repair, run DISM and then sfc again.
-
Windows errors
Check whether the Windows image is damaged
DISM /Online /Cleanup-Image /CheckHealth
Where: Command Prompt or Terminal as administrator.
Only reports whether Windows has already detected damage in its image (healthy, repairable or not repairable). It does not repair anything and takes seconds.
-
Drive
Check the drive without restarting
chkdsk C: /scan
Where: Command Prompt or Terminal as administrator.
Checks the file system of drive C: while you keep using the computer (NTFS drives only). It is the quickest way to find out if there are errors.
-
Drive
Fix drive errors
chkdsk C: /f
Where: Command Prompt or Terminal as administrator.
Fixes file system errors. Since drive C: is in use, Windows offers to check it on the next restart: answer Y and restart.
-
Drive
Find bad sectors
chkdsk C: /r
Where: Command Prompt or Terminal as administrator.
Does the same as /f and also looks for bad sectors and recovers whatever can be read. Useful when the drive shows read errors.
It can take hours on large drives. If the drive is failing, heavy use can make it worse: back up your files first.
-
Windows Update
Clear the Windows Update cache
net stop wuauserv rd /s /q %systemroot%\SoftwareDistribution net start wuauserv
Where: Command Prompt or Terminal as administrator.
Stops the update service, deletes the folder where it keeps downloads and starts it again. It is the step Microsoft suggests when updates fail over and over.
Updates already downloaded are deleted (they download again) and so is the update history shown in Windows Update.
-
Internet
Flush the DNS cache
ipconfig /flushdns
Where: Command Prompt or Terminal (no administrator needed).
Clears the website addresses Windows had stored. Useful when a page will not load on this PC but works on other devices.
-
Internet
Reset the network settings (Winsock)
netsh winsock reset
Where: Command Prompt or Terminal as administrator.
Resets the Winsock catalog, the part of Windows that programs use to connect to the internet. It helps when you are connected but programs cannot browse, for example after uninstalling an antivirus or a VPN.
Restart afterwards. If that is not enough, Windows has «Network reset» in Settings › Network & internet › Advanced network settings.
-
Won't boot
Restart into the advanced startup options
shutdown /r /o
Where: Command Prompt or Terminal (no administrator needed).
Restarts the computer straight into the advanced options menu: System Restore, Startup Repair, Uninstall Updates and Safe Mode.
-
Won't boot
Rebuild the boot configuration
bootrec /rebuildbcd
Where: Recovery Environment › Troubleshoot › Advanced options › Command Prompt.
Searches the drives for Windows installations and recreates the boot configuration (BCD). It is one of Microsoft's steps for errors such as 0xc000000e or 0xc0000225.
Try Startup Repair first: it does this and more automatically.
-
Won't boot
Repair system files without starting Windows
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
Where: Recovery Environment › Troubleshoot › Advanced options › Command Prompt.
Does the same as sfc /scannow, but on a Windows installation that does not start. From the Recovery Environment, the Windows drive may have another letter: check it first with dir C:, dir D:, etc.
-
Diagnostics
Test the RAM
mdsched
Where: Windows + R (Run) or Command Prompt.
Opens Windows Memory Diagnostic. Choose «Restart now and check for problems»: when Windows starts again it shows you the result.
-
Diagnostics
Battery report
powercfg /batteryreport
Where: Command Prompt or Terminal (no administrator needed).
Creates a report with the original and current battery capacity, the cycle count and the usage history. Read it easily with our battery health tool.
-
Diagnostics
DirectX report (parts and drivers)
dxdiag
Where: Windows + R (Run) or Command Prompt.
Shows the processor, memory, graphics card, display and drivers. With «Save All Information» you get a text file with all of it.
-
Diagnostics
See Windows errors
eventvwr
Where: Windows + R (Run) or Command Prompt.
Opens Event Viewer. Under Windows Logs › System you find the errors, including blue screens (source «BugCheck»), with their code to look up in Windows error codes.
-
Diagnostics
See the computer model and parts
msinfo32
Where: Windows + R (Run) or Command Prompt.
Opens System Information: maker, model, BIOS version, processor and installed memory.
-
Drivers and apps
Back up all drivers
pnputil /export-driver * D:\drivers
Where: Command Prompt or Terminal as administrator.
Copies every installed driver to a folder (replace D:\drivers with a folder on a USB stick or external drive). Very handy before reinstalling Windows.
-
Drivers and apps
Install the saved drivers
pnputil /add-driver D:\drivers\*.inf /subdirs /install
Where: Command Prompt or Terminal as administrator.
Installs every driver in the folder at once, including its subfolders, on the devices that need them.
-
Drivers and apps
Update all programs
winget upgrade --all
Where: Command Prompt or Terminal (no administrator needed).
Uses the Windows Package Manager (winget) to update installed programs that have a new version. You can list them first with winget upgrade.
Some programs may ask for administrator permission or close to update.
-
Drivers and apps
Go back to an earlier point
rstrui
Where: Windows + R (Run) or Command Prompt.
Opens System Restore to go back to a point before a driver, program or update that caused problems. It does not touch your documents.
In what order to try them
- DISM /RestoreHealth and then sfc /scannow: they fix most Windows errors without touching your files.
- chkdsk C: /scan: if it finds drive errors, run chkdsk C: /f and restart.
- If the problem started after a change, System Restore (
rstrui). - If nothing works, Reset this PC (Settings › System › Recovery) or reinstall Windows, after backing up your files.
Command Prompt, PowerShell or Terminal?
These commands work the same in Command Prompt (cmd), PowerShell and Terminal, which opens PowerShell by default on Windows 11. What matters is opening it as administrator when the command needs it: otherwise Windows answers that you do not have permission or that elevation is required.
Frequently asked questions
Do these commands delete my files?
No. sfc, DISM and chkdsk repair Windows and the file system without deleting your documents. Still, if the drive shows errors, back up your files before repairing: a failing drive can get worse.
sfc found corrupt files but could not fix some of them. What now?
Run DISM /Online /Cleanup-Image /RestoreHealth, restart and run sfc /scannow again. If it still cannot, the options are Reset this PC or reinstalling Windows.
DISM fails or gets stuck.
DISM downloads healthy files from Windows Update, so it needs internet and a working Windows Update. If Windows Update also fails, try the command that clears its cache first.
Do they work on Windows 10 and Windows 11?
Yes, every command on this page works on both.
Commands checked against Microsoft's official documentation on November 17, 2026. Got an error code? Look it up in Windows error codes. En español