ใช้คำสั่ง SFC (System File Checker) และ DISM (Deployment Image Servicing and Management) ตรวจสอบและซ่อมแซม Integrity ของ System Files และ Component Store ของ Windows (Windows Server) Image เครื่องมือเหล่านี้มีประโยชน์มากหาก Windows ไม่เสถียร, บูตไม่ได้, Error ตอนรัน Built-in Apps/Services, หลังติดไวรัส เป็นต้น
บทความนี้ดูวิธีใช้ SFC /ScanNow, DISM /Online /Cleanup-Image /RestoreHealth, หรือ Repair-WindowsImage -Online -RestoreHealth ซ่อมแซม Image และ System Files บน Windows 10/11 และ Windows Server 2022/2019/2016
SFC /ScanNow: ใช้ System File Checker ซ่อม System Files
แนะนำให้ใช้ DISM ซ่อม Windows หลังจากตรวจสอบ Integrity ของ System Files ด้วย SFC Tool ก่อน คำสั่ง sfc /scannow สแกน Protected System Files หากหายหรือเสียหาย จะพยายามคืนค่า Original Copies จาก Windows Component Store (โฟลเดอร์ C:\Windows\WinSxS)
SFC Tool เขียน Activity ทั้งหมดไปที่ %windir%\logs\cbs\cbs.log ทุก Entry ของ SFC ใน CBS.log ถูก Tag ด้วย [SR] ดึงเฉพาะ Entry ที่เกี่ยวกับ SFC จาก Log:
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >"%userprofile%\Desktop\sfc.txt"
หาก sfc /scannow คืน Error "Windows Resource Protection found corrupt files but was unable to fix some of them" น่าจะเป็นเพราะ Tool ไม่สามารถดึงไฟล์ที่จำเป็นจาก Windows Component Store ได้ (ดูภาพด้านล่าง)

ในกรณีนี้ ลองซ่อม Component Store ของ Windows Image ด้วยคำสั่ง DISM.exe
DISM (Deployment Image Servicing and Management) Tool มีในทุก Windows ตั้งแต่ Vista
หลังซ่อม Windows Image แล้ว ลองใช้ SFC ซ่อม System Files ใหม่
ตรวจสอบสุขภาพ Windows Component Store ด้วย DISM
Switch DISM /Cleanup-Image /CheckHealth ใช้สแกน Windows Image หา Error และแก้ไข ต้องรัน DISM Commands จาก Elevated Command Prompt
รันคำสั่งตรวจสอบ Flag ของการเสียหายของ Windows Image Component Store (ไม่適用于 Windows 7/Server 2008R2) คำสั่งตรวจสอบ CBS Flag ที่ถูก Set โดย System Maintenance Process หนึ่ง:
DISM /Online /Cleanup-Image /CheckHealth
คำสั่งนี้ไม่ทำ Full Scan ของ Component Store เพียงตรวจสอบว่า Windows Image ถูก Flag ว่า Corrupt หรือไม่ และสามารถแก้ไขได้หรือไม่ ไม่มีการเปลี่ยนแปลง Image

ตัวอย่างคำสั่งคืนค่าว่า Windows 10 Image ไม่มี Corruption:
No component store corruption detected. The operation completed successfully.
รัน Full Scan ของ Windows Component Store Health:
DISM /Online /Cleanup-Image /ScanHealth
คำสั่งตรวจสอบ Windows Image ใช้เวลานาน (10-30 นาที) และคืนผล 3 แบบ:
- No component store corruption detected – DISM ไม่พบ Error ใน Component Store
- The component store is repairable – DISM พบ Error ใน Component Store และสามารถแก้ไขได้
- The component store is not repairable – DISM ไม่สามารถซ่อม Windows Component Store ได้ (ลองใช้ DISM เวอร์ชันใหม่กว่า หรือต้อง Restore Windows Image จาก Backup, Reset หรือ Reinstall Windows ทั้งหมด)

เพื่อใช้ DISM /ScanHealth Switch บน Windows 7 และ Windows Server 2008 ต้องติดตั้ง Update KB2966583 มิฉะนั้นจะเห็น Error: "Error 87. The ScanHealth option is not recognized in this context"
ในบางกรณี DISM /ScanHealth คืน Error:
- DISM Error 1726 – "The remote procedure call failed"
- DISM Error 1910 – "The object exporter specified was not found"
แน่นอนว่า Windows Image ของคุณเสียหายและต้องซ่อมแซม
ซ่อม Windows Image ด้วย DISM /RestoreHealth
เพื่อแก้ไข Corruption ใน Windows Image Component Store ต้องใช้ Option RestoreHealth ของ DISM Command Option นี้ช่วยแก้ไข Error ใน Windows Image ดาวน์โหลดและแทนที่ไฟล์ Component ที่เสียหายหรือหายไปด้วย Original Versions จาก Windows Update (คอมพิวเตอร์ต้องมี Internet Access โดยตรง) รันคำสั่ง:
DISM /Online /Cleanup-Image /RestoreHealth
ใน Windows 7/2008 R2 คำสั่งนี้รูปแบบต่างออกไป:
DISM.exe /Online /Cleanup-Image /ScanHealth
กระบวนการสแกนและซ่อม Component Store อาจใช้เวลานาน (30 นาทีขึ้นไป) DISM จะดาวน์โหลดและแทนที่ไฟล์ Component ที่เสียหาย/หายไปด้วย Original File Versions จาก Windows Update Servers
หากซ่อมสำเร็จ จะปรากฏข้อความ:
The restore operation completed successfully.

DISM /RestoreHealth: The Source Files Could Not Be Found
หากคอมพิวเตอร์ (เซิร์ฟเวอร์) ไม่มี Internet Access โดยตรง (อยู่เบื้องหลัง Proxy, หรือใช้ WSUS ภายในรับ Updates) หรือ Windows Update Service ถูกปิด/เสียหาย (วิธีซ่อม Windows Update Client) จะเกิด Error ตอนซ่อม Component Store:
- 0x800f0906 – The source files could not be downloaded. Use the source option to specify the location of the files that are required to restore the feature
- 0x800f0950 – DISM failed. No operation was performed
- 0x800F081F – The source files could not be found. Use the "Source" option to specify the location of the files that are required to restore the feature

ในทุกกรณี สามารถใช้วิธีทางเลือกได้ Source Component Store Files ได้จาก:
- Installation Disk/USB Flash Drive/ISO Image
- Mounted WIM/ESD File
- Folder \sources\SxS จาก Installation Disk
- File install.wim (esd) พร้อม Windows Installation Image
ระบุ WIM หรือ ESD File พร้อม Windows Installation Image ต้นฉบับ เป็น Source ซ่อม System Files สมมติ Mount Windows 11 ISO ไปที่ Virtual Drive D:
หมายเหตุ เพื่อซ่อม Corrupted Files ใน Component Store จาก Local Source Windows Build และ Edition ใน WIM/ESD Image ต้องตรงกับ System ของคุณ
ตรวจสอบ Windows Version ที่ติดตั้งด้วย PowerShell:
Get-ComputerInfo |select WindowsProductName,WindowsEditionId,WindowsVersion, OSDisplayVersion

แสดง Editions ใน WIM Image การติดตั้ง:
Get-WindowsImage -ImagePath "D:\sources\install.wim"
ในกรณีนี้ Windows 11 Pro Image ใน install.wim มี ImageIndex = 6

ซ่อม Component Store จาก Local WIM/ESD File ใช้ Local Source Files (ไม่ใช้ Windows Update Online Services) รันคำสั่ง (ระบุ Windows Version Index ใน Image File):
DISM /online /cleanup-image /restorehealth /source:WIM:D:\sources\install.wim:6 /limitaccess
หรือ:
DISM /online /cleanup-image /restorehealth /source:ESD:D:\sources\install.esd:6 /limitaccess

Error ที่อาจเกิดตอนรัน DISM /RestoreHealth:
- Error: 50: DISM does not support servicing Windows PE with the /Online option – หมายถึง DISM คิดว่าคุณใช้ WinPE Image แก้โดยลบ Registry Key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MiniNT - DISM Error 87: ตรวจสอบคำสั่ง DISM ว่าถูกต้อง ใช้ DISM Version สำหรับ Windows Version ของคุณ (ปกติตอน Boot ใน WinPE/WinRE)
DISM Log ของการสแกนและซ่อม System Files อยู่ที่: C:\Windows\Logs\CBS.log
หลัง Component Store ซ่อมเสร็จ รัน System File Checker Tool (sfc /scannow) น่าจะสามารถซ่อม Damaged หรือ Missing System Files ได้ (Windows Resource Protection found corrupt files and successfully repaired them)

หาก SFC.exe ไม่พบความเสียหายของ System Files จะแสดงข้อความ:
Windows Resource Protection did not find any integrity violations.
Repair-WindowsImage: ซ่อม Windows Image Component Store ด้วย PowerShell
PowerShell Version ใน Windows 10/11 และ Windows Server 2016/2019/2022 มี Cmdlet คล้าย DISM Commands ข้างต้น สแกน Windows Component Store หา Corruption:
Repair-WindowsImage -Online –ScanHealth

หากไม่พบ Error ใน Component Store จะแสดง:
ImageHealth State: Healthy
ซ่อม Windows Component Store Files:
Repair-WindowsImage -Online -RestoreHealth
หากไม่มี Internet Access โดยตรง คำสั่งนี้อาจค้างระหว่างซ่อม Image สามารถซ่อม System Components จาก Local Windows Image File (install.wim/install.esd) ที่คัดลอกมาจาก Windows 10 Installation ISO Image ต้องระบุ Windows Version Index ใน WIM File เป็น Recovery Source:
Repair-WindowsImage -Online -RestoreHealth -Source F:\sources\install.wim:5 -LimitAccess
ใช้ DISM แบบ Offline ซ่อม Windows Image
หาก Windows บูตไม่ได้ ใช้ DISM ตรวจสอบและซ่อม System Files ของ Windows Image แบบ Offline
หาก Windows บูตไม่ได้หลังติดตั้ง Updates ลอง Uninstall Latest Updates ก่อน ตามคู่มือ
- Boot อุปกรณ์จาก Windows Installation Image (ใช้ Media Creation Tool สร้าง Bootable Windows USB) กด
Shift + F10บนหน้าจอติดตั้ง Windows เริ่มต้น - ตรวจสอบ Drive Letters ใน WinPE รัน
diskpart→list vol(ในตัวอย่าง Drive Letter C:\ ถูก Assign ให้ Disk ที่ติดตั้ง Windows จะใช้ในคำสั่งถัดไป)
- ตรวจสอบ System Files และซ่อม Corrupted Files:
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
- ซ่อม Offline Windows Image ใช้คำสั่ง (ใช้ WIM File พร้อม Windows 10 Installation Image ที่ Boot มาเป็น Source ซ่อม Offline Windows Image):
Dism /image:C:\ /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim

- หากไม่มีพื้นที่ว่างพอบน Target Disk ต้องการ Drive แยก เช่น F:\ สร้าง Empty Folder
mkdir F:\scratchซ่อม Component Store ใช้ Scratch Dir:Dism /image:C:\ /Cleanup-Image /RestoreHealth /Source:D:\sources\install.wim /ScratchDir:F:\scratch
เคล็ดลับ พารามิเตอร์ DISM ที่ Admin ควรรู้:
DISM /Add-Package– ติดตั้ง MSU/CAB Update Files, รวม Security Updates เข้า Windows ImageDISM /Get-Drivers– ดูรายการ Drivers ที่ติดตั้งDISM /Add-Driver– Inject Drivers ไป Windows Installation ImageDISM /Add-Capability– ติดตั้ง Additional Windows Features ผ่าน Features on Demand (FoD) เช่น RSAT, OpenSSH Server, Windows SSH ClientDISM /Enable-Featuresและ/Disable-Features– เปิด/ปิด Windows Components (เช่น SMBv1 Protocol)Dism.exe /StartComponentCleanup– Cleanup Component Store ลบ Old Component Versions (จากโฟลเดอร์ WinSxS)Dism /set-edition– อัปเกรดจาก Evaluation เป็น Full Windows Version โดยไม่ต้อง Reinstall