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.

Contents

Synopsis

Arguments enclosed with bracekts [  ] are optional.

sfc [/scannow] [/verifyonly] [/scanfile=<filePath>] [/verifyfile=<filePath>]
    [/offbootdir=<bootDriveLetter>] [/offwindir=<windowsDriveLetter>] 
    [/scanonce] [/scanboot] [/revert] [/purgecache] [/cachesize=x] 

Description

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

/scannow
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.

/verifyonly
Scans the integrity of all protected system files right after executing the command but doesn’t repair them.

/scanfile=<filePath>
Scans the integrity of a file specified by it’s absolute path (filePath) and repairs it if modifications are identified. An example filePath is c:\windows\system32\example.dll

/verifyfile=<filePath>
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

/offwindir=<windowsDriveLetter>
Used with /offbootdir to specify the drive on which the Windows is installed so it’s system files can be updated.

/offbootdir=<bootDriveLetter>
The /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 offbootdir path.

/scanonce
Scans and repairs the protected files next time Windows boots.

/scanboot
Scans and repairs the protected files every time Windows boots.

/revert
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.

/purgecache
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.

/cachesize=x
Changes the cache size to fulfill the user’s needs. The parameter is specified as a number of megabytes.

Exit Status

sfc.exe returns 0 on success and 1 if an error occurs.

Examples

To immediatly scan and restore damaged system files:

sfc /scannow

To scan the integrity of an example file without repairing it:

sfc /verifyfile=c:\windows\system32\example.dll

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

Compatibility

sfc.exe utility works on Windows Vista and later versions of Windows.

History

Verifyonly, scanfile, verifyfile, offbootdir and offwindir flags were introduced in Windows Vista.

See Also