sfc.exe utility scans the integrity of all system files protected by the Windows File Protection (WFP) and has the ability to replace the incorrect versions with the correct Microsoft versions. To run the utility the user must have administrator privileges.
Arguments enclosed with bracekts [ ] are optional.
sfc [/scannow] [/verifyonly] [/scanfile=<filePath>] [/verifyfile=<filePath>] [/offbootdir=<bootDriveLetter>] [/offwindir=<windowsDriveLetter>] [/scanonce] [/scanboot] [/revert] [/purgecache] [/cachesize=x]
The sfc utility has a number of flags with the
/scannow being the most used one. The utility can be run on all Windows machines as well as from Windows recovery console, though not all flags and options are supported on all operating systems. Refer to the “Compatibility” section below for a synopsis of platform-supported flags.
The options are as follows:
Lists the existing flags
Scans the integrity of all protected system files and repairs the files that are corrupt or modified right after executing the command. Those files are restored to their default values.
Scans the integrity of all protected system files right after executing the command but doesn’t repair them.
Scans the integrity of a file specified by it’s absolute path (filePath) and repairs it if modifications are identified. An example filePath is
Scans the integrity of a file specified by it’s absolute path (FilePath) but doesn’t repair it. An example filePath is c:\windows\system32\example.dll
/offbootdir to specify the drive on which the Windows is installed so it’s system files can be updated.
/offbootdir=<bootDriveLetter> specifies the letter associated with the drive that needs to be repaired. It’s used with
/offwindir=<windowsDriveLetter>. Here is an example of how these two commands are used in the Windows Recovery Console.
sfc /scannow /offbootdir=d:\ /offwindir=d:\windows
It scans and repairs the files specified by the
offwindir flag using the original Microsoft files found on
Scans and repairs the protected files next time Windows boots.
Scans and repairs the protected files every time Windows boots.
This command is used to cancel preciously executed commands. For example if the user executed the
/scanboot command, which runs the scan every time Windows boots, running the
/revert command will turn turn it off.
Deletes the files from Windows cache folder where it stores the original system files once they get modified. User must use this command with caution because it can lead to system failures. The command also runs the scan and fills the cache folder with copies of current system files.
Changes the cache size to fulfill the user’s needs. The x parameter is specified as a number of megabytes.
sfc.exe returns 0 on success and 1 if an error occurs.
To immediatly scan and restore damaged system files:
To scan the integrity of an example file without repairing it:
To scan and repair an example file from the Windows Recovery Console with Windows instalation cd in the drive f:
sfc /scanfile=d:\windows\system32\example.dll /offbootdir=f:\ /offwindir=d:\windows
sfc.exe utility works on Windows Vista and later versions of Windows.
offwindir flags were introduced in Windows Vista.