Share via


sfc

適用於:Windows Server 2022、Windows Server 2019、Windows Server 2016、Windows Server 2012 R2、Windows Server 2012

掃描並驗證所有受保護系統檔案的完整性,並以正確的版本取代不正確的版本。 如果此命令發現受保護的檔案已被覆寫,它會從 systemroot\ 資料夾擷取正確的檔案版本,然後取代不正確的檔案。

重要

您必須以管理員群組成員的身份登入才能執行此命令。

語法

sfc [/scannow] [/verifyonly] [/scanfile=<file>] [/verifyfile=<file>] [/offwindir=<offline windows directory> /offbootdir=<offline boot directory> /offlogfile=<log file path>]

參數

參數 描述
/scannow 掃描所有受保護系統檔案的完整性,並盡可能修復有問題的檔案。
/verifyonly 掃描所有受保護系統檔案的完整性,而不執行修復。
/scanfile <file> 掃描指定檔案的完整性 (完整路徑和檔案名稱),並在偵測到時嘗試修復任何問題。
/verifyfile <file> 驗證指定檔案的完整性 (完整路徑和檔案名稱),而不執行修復。
/offwindir <offline windows directory> 指定離線 Windows 目錄的位置,以進行離線修復。
/offbootdir <offline boot directory> 指定離線開機目錄的位置,以進行離線修復。
/offlogfile=<log file path> 指定除預設以外要儲存記錄檔的位置。
/? 在命令提示字元顯示說明。

範例

若要驗證 kernel32.dll 檔案,請輸入:

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

若要設定 kernel32.dll 檔案的離線修復搭配設定為 D: 的離線開機目錄,且離線視窗目錄設定為 D:\Windows,請輸入:

sfc /scanfile=D:\windows\system32\kernel32.dll /offbootdir=D:\ /offwindir=d:\windows