Using SFC

Views: 1

In my previous blog, which you can find here, I discussed the DISM command. In this post, using SFC, I discuss a related command, the System File Checker. This is available in Windows 11 and other versions of Windows. It allows you to scan for and restore corruptions in Windows system files.
Let´s start.

What is SFC?

It is a built in command line utility that helps you repair corrupted or missing system files. It is used to troubleshoot issues related to system instability, crashes, or other behavior that may be caused by system file corruption.

How does SFC work?

SFC scans the integrity of all protected system files and replaces incorrect versions with the correct Microsoft versions. It uses the Windows File Protection feature to ensure critical system files are intact and in their original versions. If it finds a file that has been corrupted or altered, it replaces it with the correct version from the Windows Component Store, which is stored in a compressed folder located at C:\Windows\WinSxS.

using sfc folder winsxs example

How do we use SFC?

First we need to start a command prompt.
Go to the windows search bar, and type “cmd”.

search bar cmd

Next, in the search results, select “Run as administrator”.

run cmd as administrator

A message appears, “Do you want to allow this app”, click Yes.
In the Command Prompt window, type the following command and press Enter: sfc /scannow

using sfc run sfc scannow

The scanning process will take some time. SFC will scan all protected system files and replace corrupted files with a cached copy from C:\Windows\WinSxS.

When the scan is complete, you receive a message with the results of the scan. Common messages:
No integrity violations: system files are intact.
Found corrupt files and successfully repaired them: SFC found and repaired the corrupted files.
Found corrupt files but was unable to fix some of them: SFC found corrupted files but could not repair them. You might need to use the Deployment Imaging Service and Management Tool (DISM) to fix the underlying Windows image. See my post here for an explanation.

After DISM has completed its repair, run the SFC scan again.

Conclusion

The System File Checker is a powerful tool for repairing corrupted system files and ensuring system integrity. If you run SFC regularly, you can maintain the stability and reliability of your Windows operating system. If SFC encounters issues it cannot fix, use DISM to repair the Windows image. This is a recommended next step.

SFC vs DISM

Both are utilities in Windows to maintain system integrity, but they function differently and serve different purposes.

SFC

Primary purpose: scan the integrity of all protected system files and replaces corrupted, changed, or damaged versions with the correct versions from the Windows Component Store.
Scope: the focus is specifically on system files that are protected by Windows File Protection. These are core files required for the operating system to run properly.

DISM

Primary Purpose: to service and prepare Windows images, including repairing the underlying Windows image that SFC relies on. You can also use it to add or remove features and packages and to manage drivers.
Scope: works on the entire Windows image, which includes the Component Store, and is capable of performing more comprehensive repairs than SFC.
DISM checks the health of the Windows image and can repair it if necessary. This includes checking for and fixing corruption within the Component Store, which SFC uses to repair system files.

How they work together

You use SFC and DISM often together to repair system issues. If SFC finds corrupted files but cannot repair them, it indicates that the Component Store might be corrupted.

Sequence of use:

Run DISM first, use DISM /Online /Cleanup-Image /RestoreHealth to check and repair the Component Store.

Run SFC after, use sfc /scannow to check and repair system files using the now-repaired Component Store.

Conclusion

SFC checks and repairs the integrity of protected system files.
DISM checks and repairs the Windows Component Store. And it fixes deeper corruption issues that might affect the system files.

Together, these tools help maintain the stability and integrity of your Windows operating system. If you encounter issues that SFC cannot resolve, run DISM to help fix the underlying problems, allowing SFC to then successfully repair the system files.

Parameters

The sfc command has several parameters. I show the main parameters and their functions. I recommend you to explore these parameters on the internet.

/scannow: scans the integrity of all protected system files and repairs files with problems when possible.
/verifyonly: scans the integrity of all protected system files but does not perform any repairs.
/scanfile: scans the integrity of the specified file. If it detects a problem it tries to repair the file.
/verifyfile: verifies the integrity of the specified file but does not perform any repairs.
/offbootdir: for offline repair, specifies the location of the offline boot folder.
/offwindir: for offline repair, specifies the location of the offline Windows folder.
/offlogfile: for offline repair, specifies the path to the log file.

What are protected system files?

These are critical files necessary for the operating system to function correctly. These files are part of the Windows operating system’s core and are protected to ensure system stability and security. They include system libraries (DLL), executables (EXE), and other critical files. The location and the types of files typically included:

Location of protected system files

Protected system files are primarily located in the following folders:

C:\Windows\System32: the main folder for 64-bit system files on a Windows installation. It contains DLLs, EXEs, and other critical system files.

C:\Windows\SysWOW64: contains 32-bit system files on a 64-bit Windows installation. It also includes essential system DLLs and EXEs needed for running 32-bit applications.

C:\Windows\WinSxS: Windows Component Store. This folder holds multiple versions of system files used for system recovery and the SFC tool.

Types of protected system files

Protected system files include, but are not limited to:

System Libraries (DLL): Dynamic Link Libraries are essential for running software applications and OS functions.
Examples: kernel32.dll, user32.dll, gdi32.dll.

Executables (EXE): files necessary for running system processes and applications.
Examples: explorer.exe, notepad.exe, cmd.exe.

Configuration Files: files the system relies on for settings and operations.
Examples: system.ini, win.ini.

Drivers (SYS Files): system drivers required for hardware components to function correctly.
Examples: disk.sys, ntfs.sys.

Fonts: system fonts used by the operating system and applications.
Examples: arial.ttf, times.ttf.

Locations

C:\Windows\System32
Common Files: kernel32.dll, user32.dll, notepad.exe

C:\Windows\SysWOW64
Common Files: kernel32.dll, user32.dll (32-bit versions)

C:\Windows\WinSxS
Common Files: kernel32.dll.mui, user32.dll.mui

Why these files are protected

Stability: they ensure the operating system runs smoothly without crashes or errors.
Security: to protect these files prevents malicious software from altering critical system components.
Functionality: many applications and system processes rely on these files to function correctly.

Conclusion

Protected system files are located mainly in the System32, SysWOW64, and WinSxS folders and include critical DLL, EXE, drivers, and configuration files. These files are vital for the operating system’s functionality, stability, and security, and Windows employs various mechanisms to protect them from unauthorized changes.

SFC and DISM logs

Both tools generate log files that you can review for detailed information about the scans and repairs performed.
SFC Log is C:\Windows\Logs\CBS\CBS.log.
DISM Log is C:\Windows\Logs\DISM\dism.log.

Running SFC and DISM in Safe Mode

If you encounter issues running SFC or DISM in normal mode, you can try running them in Safe Mode. This loads only essential system services and drivers, potentially reducing conflicts.

SFC Help

You can access SFC help by entering sfc /? in the command prompt. This shows you all the options available. Refer to the internet for a more extensive explanation.

sfc help screen

This brings us to the end of my post on using SFC.

Thank you for taking the time to read my post on using SFC.
I hope you found it enjoyable and insightful.
Stay tuned for more content that is coming soon.

If you like what you read, please consider sharing it with others who might find it helpful.

Disclaimer

All tips and methods mentioned in this blog are tested on Windows 11. Please note that results may vary on other operating systems or versions of Windows. Adapt the instructions accordingly.

Copyright

© 2024 Henny Staas/safecomputer.org. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Henny Staas/safecomputer.org with appropriate and specific direction to the original content.


Posted

in

by

Thank you for reading.

Comments

Leave a Reply

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