How to Repair Windows Using Command Prompt (CMD)
Are you experiencing Windows errors, corrupted system files, unexpected crashes, or problems installing updates? Before reinstalling Windows or taking your computer to a repair shop, you can try fixing these issues using Command Prompt (CMD).
Windows includes several command-line tools that can scan your computer for corrupted system files, repair damaged Windows components, check your hard drive for errors, and troubleshoot boot-related problems.
Some of the most useful commands include SFC (System File Checker), DISM (Deployment Image Servicing and Management), and CHKDSK (Check Disk). Each tool handles a different type of problem, so running them in the right order can help restore Windows without deleting your personal files.
In this guide, I’ll explain how to repair Windows using Command Prompt.
How to Repair Windows Using Command Prompt (CMD)

To repair Windows using Command Prompt, open CMD as an administrator and run the DISM command DISM /Online /Cleanup-Image /RestoreHealth. Once it finishes, run sfc /scannow to scan and repair corrupted system files. You can also use chkdsk C: /scan to check your Windows drive for file system errors.
Before running these commands, save your work and close open applications. Some repairs may take several minutes, and certain operations require restarting your computer.
Let’s go through the different repair methods step by step.
1: Open Command Prompt as an Administrator
Before running any repair commands, you need to open Command Prompt with administrator privileges. Otherwise, Windows may prevent certain commands from making changes to system files.
Press Windows + S on your keyboard to open Windows Search.
Type CMD or Command Prompt in the search box. When the Command Prompt result appears, right-click it and select Run as administrator.
If Windows displays a User Account Control (UAC) prompt asking whether you want to allow the app to make changes to your device, click Yes.
A black Command Prompt window will appear. You can now enter commands to scan and repair Windows.
To confirm that you’re using an elevated Command Prompt, look at the window title. It should display Administrator: Command Prompt.
If you cannot access your Windows desktop, you can also open Command Prompt through the Windows Recovery Environment. We’ll cover that in a later step.
2: Run DISM to Repair the Windows Image
The first repair tool you should try is DISM (Deployment Image Servicing and Management).
DISM checks the Windows component store, which contains the files Windows uses to maintain and repair the operating system. If this component store becomes corrupted, Windows might struggle to repair system files or install updates.
To begin, enter the following command in the Administrator Command Prompt:
DISM /Online /Cleanup-Image /RestoreHealth
Press Enter to start the repair process.
Windows will now scan its component store for corruption and attempt to repair detected problems. By default, DISM can use Windows Update to obtain the required replacement files.
The process may take several minutes. Sometimes, the progress percentage might appear stuck for a while. Don’t close Command Prompt or restart your computer while the operation is running.
Once DISM finishes, you’ll see a completion message. Ideally, it should report that the restore operation completed successfully.
If DISM cannot find the required source files, you might need a compatible Windows installation image to perform the repair.
3: Run System File Checker (SFC)
After repairing the Windows image with DISM, the next step is to run System File Checker (SFC).
SFC scans protected Windows system files and replaces corrupted or missing versions with healthy copies when possible.
In the same Administrator Command Prompt window, type:
sfc /scannow
Press Enter to begin the scan.
Windows will start verifying the integrity of protected system files. You’ll see a progress indicator showing how much of the scan has been completed.
Wait until the verification reaches 100%. Depending on your computer’s performance and the number of files that need checking, this process may take several minutes.
Once completed, Windows will display one of the following results.
Windows Resource Protection did not find any integrity violations: This means SFC didn’t detect any corrupted protected system files.
Windows Resource Protection found corrupt files and successfully repaired them: Windows detected damaged files and replaced them with healthy versions.
Windows Resource Protection found corrupt files but was unable to fix some of them: Some problems remain. Check the CBS.log file for more information and consider running DISM again before repeating the SFC scan.
If SFC successfully repairs files, restart your computer and check whether the original Windows problem has been resolved.
4: Check Your Hard Drive for Errors Using CHKDSK
Sometimes, Windows problems aren’t caused by corrupted system files. Issues with the hard drive or file system can also cause crashes, slow performance, unexpected errors, and problems accessing files.
That’s where CHKDSK (Check Disk) comes in.
This command checks a drive for file system errors and can help identify problems with its storage structure.
To scan your Windows drive, enter:
chkdsk C: /scan
Press Enter to start the scan.
Here, C: represents the Windows drive. If Windows is installed on another drive, replace C: with the correct drive letter.
The /scan parameter performs an online scan of the NTFS file system without requiring you to take the volume offline.
Once the scan finishes, Command Prompt will display whether Windows detected any file system problems.
If Windows reports errors that require an offline repair, you can run:
chkdsk C: /f
This command attempts to fix file system errors. If the drive is currently in use, Windows may ask whether you want to schedule the check for the next restart.
Type Y and press Enter to confirm. Restart your computer to allow CHKDSK to complete the repair.
Before running disk repairs, make sure you have a backup of important files. If your drive is showing signs of physical failure, repeated repair attempts may not be the safest option.
5: Repair Windows Boot Problems Using CMD
Is your computer stuck on the Windows logo, displaying a boot error, or repeatedly restarting before reaching the desktop?
In that case, you may need to repair Windows startup files rather than ordinary system files.
Windows provides several boot repair commands that you can run through the Windows Recovery Environment (WinRE).
First, enter the Windows Recovery Environment. If Windows still opens, go to Settings > System > Recovery and select Restart now next to Advanced startup.
If Windows won’t start, you can interrupt the startup process a few times or boot from a Windows installation USB and select Repair your computer.
Once the recovery screen appears, navigate to:
Troubleshoot > Advanced options > Command Prompt
Now you can try the following command:
bootrec /scanos
This scans for Windows installations that aren’t currently included in the Boot Configuration Data (BCD) store.
Next, you can run:
bootrec /rebuildbcd
This command scans for Windows installations and attempts to rebuild the boot configuration data.
Depending on your system’s boot configuration, additional repairs may be required. Modern UEFI-based computers often need the EFI System Partition and its boot files repaired separately.
Be careful when using boot repair commands. Incorrect changes to boot configuration can make an already unbootable computer harder to recover.
6: Repair Windows Update Components Using CMD
If Windows Update keeps failing, displays installation errors, or gets stuck downloading updates, resetting its update cache may help.
Open Command Prompt as administrator and enter these commands one at a time:
net stop wuauserv
net stop bits
These commands stop the Windows Update and Background Intelligent Transfer Service.
Next, rename the existing update download cache folder:
ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
Now restart the services:
net start wuauserv
net start bits
Windows will create a fresh SoftwareDistribution folder when required.
This process doesn’t uninstall your existing Windows updates. However, Windows Update may need to download update files again.
If a service refuses to stop or a folder cannot be renamed, check whether another update operation is running before trying again.
Restart Windows and Check the Repair Results
Once you’ve completed the necessary repair commands, restart your computer.
You can do this directly from Command Prompt by entering:
shutdown /r /t 0
Press Enter, and Windows will restart immediately.
After your computer boots, check whether the original problem has disappeared. Open the applications that were crashing, try installing Windows updates, or test the features that weren’t working properly.
You don’t need to run every command in this guide if your computer is working normally. Start with DISM and SFC for common Windows corruption issues, and use CHKDSK or boot repair commands only when the problem points to storage or startup errors.
FAQs
1. Can I Repair Windows 11 Using CMD Without Losing Data?
Yes. Commands such as DISM, SFC, and CHKDSK are designed to repair Windows components, protected system files, and file system errors. They don’t normally delete personal documents, pictures, or installed applications. However, it’s always a good idea to back up important files before performing repairs.
2. Which CMD Command Is Best for Repairing Windows?
The DISM /Online /Cleanup-Image /RestoreHealth command is useful for repairing the Windows component store. After running DISM, use sfc /scannow to check and repair protected system files.
Both commands work together to address many common Windows corruption problems.
3. How Long Does It Take to Repair Windows Using CMD?
It depends on your computer’s hardware, Windows installation, and the type of problem. An SFC scan may take around 10 to 30 minutes, while DISM can take longer. CHKDSK may also require additional time, especially when checking a large or problematic drive.
4. Can I Run CMD Repair Commands Without Logging Into Windows?
Yes. You can access Command Prompt through Windows Recovery Environment (WinRE) without logging into your Windows desktop.
Navigate to Troubleshoot > Advanced options > Command Prompt to access the repair tools.
Keep in mind that the Windows drive letter might be different in recovery mode. Check the correct drive before running offline repair commands.
5. What Should I Do If SFC Cannot Repair Corrupted Files?
First, run the DISM RestoreHealth command to repair the Windows component store. Once DISM completes successfully, run sfc /scannow again.
If the problem continues, examine the CBS.log file to identify which system files couldn’t be repaired. You may need a compatible Windows repair source or additional troubleshooting.
6. Is It Safe to Use DISM and SFC Commands?
Yes. Both are Microsoft-provided Windows repair utilities. They are generally safe when used with the correct commands. However, you should avoid interrupting an ongoing repair process or using unfamiliar commands copied from untrusted sources.
