How to Repair Windows Using Command Prompt

Use Command Prompt to fix Windows by running DISM, then SFC as administrator, with separate repair commands for disk and startup problems.

Oct 16, 2026
•
10 min read
Technobezz
How to Repair Windows Using Command Prompt

Contents

Don't Miss the Good Stuff

Get tech news that matters delivered to your inbox.

To repair Windows using Command Prompt, open it as administrator, run DISM.exe /Online /Cleanup-Image /RestoreHealth, then run sfc /scannow. This repairs the Windows component store first, then checks and repairs protected system files.

Use that sequence when Windows still opens. If Windows cannot start, open recovery Command Prompt and target the installed Windows drive with offline commands. These tools work on Windows 11 and Windows 10, but they cannot fix every app, setting, or hardware problem.

The short version

  • Start here: Open Command Prompt as administrator and run DISM before SFC.
  • Let repairs finish: Wait for DISM to complete successfully and SFC verification to reach 100%.
  • For startup failures: Open Windows recovery and identify the installed Windows drive before using offline commands.
  • Match the repair: Use CHKDSK for file-system errors and boot repair for startup configuration problems.

RepairWhat it addressesWhen to use it
DISMWindows component-store corruptionBefore SFC, with a suitable repair source if needed
SFCDamaged protected system filesAfter successful DISM repair
Offline DISMComponent-store corruption in an offline installationFrom recovery, with a suitable source
Offline SFCProtected files in an offline installationAfter identifying the boot and Windows directories
Revert pending actionsStartup failure after servicingAgainst the offline Windows installation only
CHKDSK with /fFile-system errorsWhen the affected volume needs repair
CHKDSK with /rBad sectors and readable-data recoveryFor relevant storage problems
Startup RepairSome system-file and boot-configuration failuresBefore manual boot repair
BCDBootWindows boot files and boot configurationFor diagnosed boot problems
System RestoreSystem configuration problemsWhen a usable restore point exists
Windows Update reinstallWindows problems that persist after repairsOn eligible Windows 11 PCs
Reset this PCProblems requiring Windows reinstallationWhen other repairs fail, with apps and settings removed

Open Command Prompt as administrator

Search Windows for Command Prompt, right-click Command Prompt, and select Run as administrator. Select Yes and supply administrator credentials if requested. Run the desktop repair commands in that window.

Windows 11 search for cmd with Command Prompt as the best match and Run as administrator in its options.
Click to expand
Search for cmd, then select Run as administrator for Command Prompt.

Save your work before repairs that require a restart, and back up recoverable files before operations that change disks or reinstall Windows. If the desktop is unresponsive, follow the steps to restart a computer that is unresponsive, then choose the desktop or recovery route based on whether Windows starts.

Repair the Windows component store with DISM

Begin with DISM to repair the Windows component store. In administrator Command Prompt, enter the following command and press Enter.

DISM.exe /Online /Cleanup-Image /RestoreHealth

Wait for successful completion before moving on to SFC. Windows Update supplies repair files by default. The /Online switch targets the operating system currently running, so it will not target your installed Windows system when you run it from recovery Command Prompt.

Administrator Command Prompt after DISM /Online /Cleanup-Image /ScanHealth, reporting no component store corruption.
Click to expand
DISM checking the component store with /ScanHealth in an administrator Command Prompt on Windows 11. The /RestoreHealth repair runs in the same window.

If DISM cannot obtain repair files, provide a suitable repair source. Its version, servicing level, architecture, edition, and required languages must be appropriate for your Windows installation. Replace the example folder below with the actual source location, then run the command.

DISM /Online /Cleanup-Image /RestoreHealth /Source:C:\RepairSource\Windows /LimitAccess

The /LimitAccess switch prevents DISM from falling back to Windows Update. A source older than your installation's servicing level can fail. If you cannot supply a suitable source, use the repair reinstall option below.

Scan and repair system files with SFC

After DISM completes successfully, run System File Checker in the same administrator Command Prompt. Enter the following command and press Enter.

sfc /scannow

Leave the window open until verification reaches 100%, then check whether the original problem is resolved. SFC repairs protected Windows system files, so an unresolved problem may need a different repair. Use CHKDSK for file-system errors or the recovery options below when system-file repairs are insufficient.

Administrator Command Prompt after sfc /scannow, with verification 100% complete and no integrity violations found.
Click to expand
sfc /scannow on Windows 11: verification reached 100% and Windows Resource Protection found no integrity violations.

When SFC cannot perform the requested operation, Microsoft recommends running it in Safe Mode. Enter recovery using the steps below, then select Troubleshoot > Advanced options > Startup Settings > Restart. Press 6 or F6 for Safe Mode with Command Prompt, sign in, and run sfc /scannow again.

Open recovery when Windows cannot start

From the sign-in screen, hold Shift while selecting Power > Restart. Once recovery opens, select Troubleshoot > Advanced options > Command Prompt. This opens a separate recovery environment rather than your normal Windows desktop.

Windows Recovery Advanced options screen with Startup Repair, Startup Settings, Command Prompt, Uninstall Updates, UEFI Firmware Settings and System Restore.
Click to expand
Advanced options in Windows Recovery on Windows 11, reached through Troubleshoot. Command Prompt, Startup Repair and System Restore all start from here.

You can also reach recovery from Windows 11 through Settings > System > Recovery, then select Restart now under Advanced startup. On Windows 10, open Settings > Update & Security > Recovery, then select Restart now under Advanced startup. Follow the same recovery path to Command Prompt.

Windows 11 Settings, System, Recovery page with the Restart now button under Advanced startup.
Click to expand
Settings, System, Recovery on Windows 11. Restart now under Advanced startup opens Windows Recovery.

Recovery can open automatically after repeated startup failures. To trigger it manually, hold the power button until the PC shuts down when the Windows or manufacturer logo appears, repeat once, then start the PC a third time. Select Advanced options, then select Troubleshoot > Advanced options > Command Prompt.

If local recovery does not work, boot compatible Windows installation media. Complete the language and keyboard screens, select Next, then select Repair my PC and Next to enter recovery. Older installation media may show Repair your computer instead. Select Troubleshoot > Advanced options > Command Prompt.

An encrypted PC may request its BitLocker recovery key before you can proceed. On another device, open your Microsoft account recovery keys, sign in, and match the displayed key ID. Enter the matching recovery key on the PC you are repairing. A printed or USB-saved recovery key is another option.

Repair the installed Windows system offline

Drive letters can change in recovery, so never assume your Windows installation is on C:. To inspect the volumes, run the following commands one at a time, pressing Enter after each; the last command leaves DiskPart.

diskpart
list vol
exit

Identify the installed Windows volume and confirm which volume contains its Windows directory before continuing. To confirm it, run bcdedit at the same prompt and read its Windows Boot Loader section, where osdevice names the partition that holds Windows. The examples below use D: for that installation, but you must substitute its actual path. Do not target X:, which belongs to the recovery environment.

DiskPart list vol output with the Windows volume, above the Windows Boot Loader section of bcdedit with its osdevice line.
Click to expand
list vol in DiskPart, then the Windows Boot Loader section of bcdedit, both run here in an administrator Command Prompt in Windows 11. In recovery the letters can differ, so read them there.

For offline DISM repair, you also need a suitable repair source. Replace both the Windows image path and the source path in this example before running it.

DISM /Image:D:\ /Cleanup-Image /RestoreHealth /Source:E:\RepairSource\Windows

Wait for DISM to complete successfully, then run offline SFC using the actual offline boot directory and Windows directory. Those directories can be on different partitions, so confirm both locations. The following example assumes both are on D:.

sfc /scannow /offbootdir=D:\ /offwindir=D:\Windows

If Windows stopped starting immediately after servicing, reverting pending servicing actions is a separate recovery option. Use this only against the installed offline Windows system, never the running operating system or the recovery environment itself. Replace D: with the installed Windows volume's actual letter, run the following command, then restart.

DISM /Image:D:\ /Cleanup-Image /RevertPendingActions

Repair file system errors with CHKDSK

Use CHKDSK when the problem involves file-system errors rather than damaged Windows components. In administrator Command Prompt, run the following against the affected volume, replacing C: when checking a different drive or using its recovery-environment letter.

chkdsk C: /f

If Windows asks to schedule the check at the next restart, press Y, press Enter, and restart the PC. CHKDSK repairs file-system errors; it does not replace the Windows components handled by DISM and SFC.

For storage problems involving bad sectors or unreadable data, use the following command to check bad sectors and attempt readable-data recovery. It includes the repairs performed by /f and takes substantially longer, so reserve it for relevant storage problems. Back up recoverable files before you run it.

chkdsk C: /r

If asked to schedule the check, press Y, press Enter, and restart. Neither CHKDSK option can physically repair failing storage hardware. If the underlying problem is hardware failure, further Windows file repairs cannot fix it.

Administrator Command Prompt after chkdsk C: /r, asking whether to schedule the check for the next restart.
Click to expand
chkdsk C: /r on the drive Windows is running from asks to schedule the check for the next restart. Press Y to schedule it; this example answered N.

Repair boot files for startup problems

For a PC that cannot start, try automatic Startup Repair before manually rebuilding boot files. In recovery, select Troubleshoot > Advanced options > Startup Repair > Restart. Supply the BitLocker recovery key if requested.

If the problem involves damaged Windows boot files or boot configuration, BCDBoot can recreate them. Open recovery Command Prompt, identify the volumes using DiskPart as described above, and confirm the installed Windows directory. Run the following with its actual drive letter, then restart.

bcdboot D:\Windows

The basic BCDBoot repair does not require formatting a partition. Its optional /s switch changes firmware-entry behavior and requires a confirmed target system partition. Leave partition formatting and extra partition switches out of a routine repair.

Bootrec remains available for targeted boot repairs, but its master boot record and boot-sector operations mainly concern BIOS/MBR configurations. Commands such as bootrec /fixmbr and bootrec /fixboot are not a universal Windows 11 UEFI repair sequence. If BCDBoot does not resolve the failure, choose a recovery option suited to the problem.

Choose a recovery option when commands fail

System Restore can restore system configuration without rolling back personal files, provided you have an existing usable restore point. From running Windows, enter the following command to open it.

rstrui.exe

Select Next and choose a restore point, selecting Show more restore points if needed. Optionally select Scan for affected programs, then select Next > Finish. When Windows cannot start, open System Restore through Troubleshoot > Advanced options > System Restore in recovery.

On eligible Windows 11 PCs, open Settings > System > Recovery, then select Reinstall now under Fix problems using Windows Update. Select OK, keep power and internet connected, and restart when installation finishes. This reinstalls the current Windows version while preserving apps, files, and settings. The option requires the relevant Windows updates and may be unavailable on PCs whose updates your organization manages. On Windows 10, or when Reinstall now is unavailable, you can reinstall in place from Windows installation media while signed in: open setup.exe on the media, select Change what to keep, choose Keep personal files and apps, then select Next and Install.

Windows 11 Settings, System, Recovery page with the Reinstall now button under Fix problems using Windows Update.
Click to expand
Reinstall now, under Fix problems using Windows Update in Settings, System, Recovery on Windows 11.

A reset is a further fallback when repairs fail. To reset a laptop through Windows recovery, select Troubleshoot > Reset this PC. Choose Keep my files to retain personal files, while understanding that apps and settings are removed. Choose Cloud download when local installation files are damaged, then review the offered settings and complete the displayed reset steps. Have your BitLocker recovery key ready, because recovery may ask for it.

Frequently Asked Questions

Can you run Windows repair commands in Windows Terminal?

Yes, Terminal can host an administrator Command Prompt tab. Right-click the Windows Terminal icon, right-click its application title, and select Run as administrator. Open the arrow beside the plus button and select Command Prompt; Terminal does not use a separate repair engine.

Do DISM CheckHealth and ScanHealth repair Windows?

No, DISM /Online /Cleanup-Image /CheckHealth checks recorded corruption status, while DISM /Online /Cleanup-Image /ScanHealth performs a corruption scan. Neither repairs the component store; /RestoreHealth performs that repair.

Can SFC check files without changing them?

Yes, sfc /verifyonly checks protected system files without repairing them. For a single file, sfc /verifyfile=FULL-PATH performs verification, while sfc /scanfile=FULL-PATH attempts repair. Replace FULL-PATH with the actual file path.

Should you restore the registry from the RegBack folder?

Do not assume that folder contains usable automatic backups. Microsoft stopped creating them by default beginning with Windows 10 version 1803. Microsoft recommends System Restore for a corrupt registry hive.

Can you prepare a recovery USB from Command Prompt?

Yes, run recoverydrive.exe while Windows works to open the Recovery Drive tool. Select Back up system files to the recovery drive, then select Next. Connect and select an empty USB drive, select Next, then select Create. Creation erases that USB, and the recovery media is intended for the device it was created for.