Fix Corrupted Files Using Command Prompt in Windows

Posted by

Corrupted files can cause some pretty frustrating problems in Windows. You may notice apps crashing, Windows features refusing to work, error messages appearing unexpectedly, or certain files becoming impossible to open. In some cases, the problem can even make Windows feel slow or unstable.

The good news is that Windows includes several Command Prompt commands that can check system files, repair corrupted components, and restore damaged Windows files. You do not always need to reset your PC or reinstall Windows to fix these problems.

The most useful tools are System File Checker (SFC) and Deployment Image Servicing and Management (DISM). SFC checks protected Windows system files and replaces corrupted versions when possible. DISM can repair the Windows component store that SFC relies on.

This guide explains how to fix corrupted files using Command Prompt in Windows, step by step. 

Fix Corrupted Files Using Command Prompt in Windows

Fix Corrupted Files Using Command Prompt in Windows
Fix Corrupted Files Using Command Prompt in Windows

To fix corrupted files using Command Prompt in Windows:

  1. Open Command Prompt as administrator by searching for Command Prompt from the Windows Start menu and selecting the administrator option.
  2. Run DISM /Online /Cleanup-Image /RestoreHealth and wait for the repair process to finish.
  3. Run sfc /scannow to scan protected Windows system files and repair corrupted files.
  4. Restart your computer after the scan finishes.
  5. Run sfc /scannow again if Windows still shows signs of corrupted files.
  6. Check the SFC results to determine whether Windows successfully repaired the corrupted files.

Step 1: Open Command Prompt as Administrator

The first thing you need to do is open Command Prompt with administrator permissions. Some repair commands cannot make the required system changes when Command Prompt is opened normally.

Click the Start button or press the Windows key on your keyboard. Type Command Prompt into the search box. When Command Prompt appears in the results, right-click it and choose Run as administrator. If Windows displays a User Account Control prompt asking whether you want to allow the app to make changes, select Yes.

You should now see a black Command Prompt window. The title bar may say Administrator: Command Prompt, which confirms that you have the required permissions.

Do not close this window while the repair commands are running. Depending on your system and the condition of Windows, some scans can take several minutes.

Step 2: Run the DISM Health Check

Before running SFC, it is a good idea to check the Windows component image. This is where DISM becomes useful.

In the administrator Command Prompt window, type the following command:

DISM /Online /Cleanup-Image /CheckHealth

Press Enter and let Windows complete the command.

This command performs a quick check to determine whether Windows has detected corruption in the component store. It does not perform a full repair by itself.

If Windows reports that the component store may be repairable, continue with the next step. Even if you are not completely sure what the result means, you can continue to the repair command.

Step 3: Scan the Windows Component Store

Now run a more detailed DISM scan by entering:

DISM /Online /Cleanup-Image /ScanHealth

Press Enter and wait for the scan to finish.

The ScanHealth command performs a deeper examination of the Windows component store. The progress percentage may appear to pause for a while. That does not necessarily mean the command has stopped working.

Give the process time to complete. Avoid closing Command Prompt, restarting the computer, or shutting down Windows while the scan is running.

If DISM detects corruption that can be repaired, continue to the next step.

Step 4: Repair Corrupted Windows Components

Now you can use DISM to repair the Windows image. Type:

DISM /Online /Cleanup-Image /RestoreHealth

Press Enter.

This command attempts to repair corruption found in the Windows component store. The process can take some time, and the progress percentage may move slowly or appear to remain at the same number temporarily.

That behavior can be normal. Be patient and allow RestoreHealth to finish.

When the operation completes successfully, you should see a message indicating that the restore operation completed successfully.

If DISM reports an error instead, note the exact error message. Do not randomly run unrelated commands because the appropriate solution depends on the error.

Step 5: Run System File Checker

Once DISM has finished, it is time to run System File Checker, commonly called SFC.

In the same administrator Command Prompt window, enter:

sfc /scannow

Press Enter.

SFC will begin checking protected Windows system files. If it finds corrupted files, Windows attempts to replace them with healthy copies.

You will see a progress percentage as the scan continues. It can take several minutes, especially on a system with a large number of files or a storage drive that is under heavy load.

Do not close Command Prompt while sfc /scannow is running. Wait until the verification reaches 100 percent.

Step 6: Understand the SFC Result

When SFC finishes, Windows displays a message explaining what happened. This result is important because it tells you whether corrupted files were found and repaired.

If Windows says Windows Resource Protection did not find any integrity violations, SFC did not find corrupted protected system files.

If it says Windows Resource Protection found corrupt files and successfully repaired them, the repair was successful. Restart your computer and check whether the original problem has disappeared.

You may also see a message saying that Windows Resource Protection found corrupt files but was unable to fix some of them. This means additional troubleshooting may be necessary.

Do not assume that an unsuccessful SFC repair means your computer is permanently damaged. It simply means Windows could not repair every affected file using the normal SFC process.

Step 7: Restart Windows

After DISM and SFC finish, restart your computer.

Click Start > Power > Restart and allow Windows to shut down and start again normally.

Restarting is important because some repaired system files may not be fully used until Windows loads again. Once your PC starts, check the problem that originally led you to run the repair commands.

For example, if an application was crashing, open it again. If Windows was displaying a system error, check whether the error has disappeared.

Step 8: Run SFC Again if Problems Continue

If you are still experiencing corruption-related problems, open Command Prompt as administrator again and run:

sfc /scannow

Running the scan again after DISM has repaired the Windows component store can sometimes resolve files that could not be repaired during the first SFC attempt.

Allow the scan to reach 100 percent and review the final message.

If SFC still reports that it cannot repair certain files, you may need to investigate the specific corruption rather than repeatedly running the same command.

Step 9: Check Your Drive for File System Errors

Sometimes what appears to be Windows file corruption is actually related to file system errors on the storage drive.

Windows provides the CHKDSK command for checking a drive.

To scan the system drive, open an administrator Command Prompt and enter:

chkdsk C: /scan

Press Enter and let Windows check the drive.

The /scan option performs an online scan of the file system. If CHKDSK reports problems that require an offline repair, Windows may recommend running a different command and scheduling the repair for the next restart.

Be careful when using more advanced CHKDSK options because some repair operations can require Windows to restart before they can run.

Step 10: Restart and Verify Your System

After completing the repair process, restart Windows one more time and test your computer.

Pay attention to whether the original symptoms have improved. Check applications that were crashing, files that were failing to open, Windows features that were malfunctioning, or error messages that were appearing repeatedly.

If everything is working normally, you have likely resolved the corrupted system files.

If problems continue, the underlying cause may be something other than Windows system-file corruption. Possible causes include failing storage hardware, problematic drivers, malware, damaged application files, Windows update problems, or hardware issues.

Faqs

Can Command Prompt repair corrupted files in Windows?

Yes. Windows provides commands such as DISM, SFC, and CHKDSK that can diagnose and repair different types of system and file system problems.

Should I run DISM or SFC first?

For stubborn Windows corruption, running DISM first and SFC afterward is a practical approach. DISM can repair the Windows component store, while SFC uses Windows system resources to check and repair protected system files.

How long does sfc /scannow take?

The time varies depending on your computer, storage speed, and the amount of data Windows needs to examine. It can take several minutes or longer. Do not interrupt the scan simply because the progress percentage appears slow.

What if SFC says it could not repair some files?

First, make sure you have run DISM /Online /Cleanup-Image /RestoreHealth and then run sfc /scannow again. If SFC continues reporting unrepaired files, additional troubleshooting may be required.

Is it safe to use Command Prompt to repair Windows?

The commands discussed in this guide are standard Windows troubleshooting commands. However, you should enter commands exactly as written. Avoid running commands from random sources when you do not understand what they do.

Will these commands delete my personal files?

The DISM and SFC commands discussed here are designed to repair Windows components and protected system files, not delete your personal documents, photos, or other personal data.

What should I do if DISM gets stuck at a percentage?

DISM can sometimes appear to pause at a particular percentage while it continues working. Give it enough time to finish before assuming that it has failed. If it eventually returns an error, use the exact error message to determine the next troubleshooting step.

Leave a Reply

Your email address will not be published. Required fields are marked *