Windows - SFC

最後更新: 2019-05-21

介紹

 

SFC.exe (System File Checker) is a utility in Windows

that allows users to scan for corruptions in Windows system files and restore corrupted files.

It will scan all protected system files, and replace corrupted files

  with a cached copy that is located in a compressed folder at

  "%windir%\winsxs\Backup folder" (win7, win10)

目錄

 


sfc

 

 * If you are running W10, W8, first run the DISM tool prior to running the System File Checker.

DISM.exe /Online /Cleanup-image /Restorehealth

Usage:

# Scans integrity of all protected system files and repairs files with problems when possible.

sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

# Verifies the integrity of the file with full path <file>.  No repair operation is performed.

sfc /VERIFYFILE=c:\windows\system32\kernel32.dll

Windows Resource Protection did not find any integrity violations.

# Scans integrity of the referenced file, repairs file if problems are identified.

sfc /SCANFILE=c:\windows\system32\kernel32.dll

Log file

C:\Windows\Logs\CBS\CBS.log
 


DISM

 

若是 W10, W8, 在執行 sfc 前必須執行以下 cmd 去確保修復檔沒有問題

# The operation completed successfully

DISM.exe /Online /Cleanup-image /ScanHealth

No component store corruption detected.

# 如果有問題, 就要用 Windows Update 獲得所需的檔案

DISM.exe /Online /Cleanup-image /Restorehealth

Opts

/Online

Targets the running operating system

DISM /Online /?

/Cleanup-Image

Performs cleanup and recovery operations on the image

DISM /Online /Cleanup-Image /?

/Cleanup-Image {/CheckHealth | /ScanHealth | /RestoreHealth}

/CheckHealth

to check whether the image has been flagged as corrupted

by a failed process and whether the corruption can be repaired.

/ScanHealth

to scan the image for component store corruption.

/RestoreHealth

to scan the image for component store corruption, and then perform repair operations automatically.

will connect to the Windows Update servers to download and replace any damaged files in the local image

[==============100.0%==============] The restore operation completed successfully.
The operation completed successfully.

/Source with /RestoreHealth

to specify the location of known good versions of files that can be used for the repair.

/Cleanup-Image /StartComponentCleanup

  • To cleanup the superseded components and reduce the size of the component store (WinSxS folder)
  • cleanup except previous versions of updated components will be immediately deleted (without a 30 day grace period)

/StartComponentCleanup with /ResetBase

All existing service packs and updates cannot be uninstalled after this command is completed.

i.e.

# Clear s2016 after win update 14.2 GB -> 7.16 GB

DISM.exe /Online /Cleanup-image /StartComponentCleanup /ResetBase

 


 

 

Creative Commons license icon Creative Commons license icon