FAQ
Q: I've seen oneliners that look handy.
E.g. like this:
sfc /scannow; DISM.exe /Online /Cleanup-image /Restorehealth; sfc /scannow; chkdsk C: /r /x /v; shutdown /r
A: Don't use them. The above contains a redantad call to sfc, doesn't check the disk before messing a lot with it and doesn't allow you to check for errors from DISM (it also scans for HDD bad sectors - who has windows on HDDs these days?)
Q: What is the official guide from Microsoft
A: https://support.microsoft.com/en-us/topic/use-the-system-file-checker-tool-to-repair-missing-or-corrupted-system-files-79aa86cb-ca52-166a-92a3-966e85d4094e
Q: I have seen others suggest different orders of execution for sfc and dism
A: The order depends on what you want: If you want the
quickest method to fix problems for the end user, then the proper order is DISM restorehealth followed by SFC scannow. But if you don't mind waiting more in order to understand the deep technical
causes of the issue then run SFC scannow first followed by DISM restorehealth followed by SFC scannow.
Background: SFC detects missing/corrupted/modified system files. It the uses the component store to fetch good versions of those system files and copy them over. If there's an issue with the component store then SFC will still report that it found a corrupted file but it will be unable to copy a good version from the component store to fix the issue. In that case, DISM /online /cleanup-image /restorehealth may repair the component store and thus allow you to run SFC again and repair your system files.
https://www.tenforums.com/performance-maintenance/161345-what-correct-order-dism-sfc-commands-fix-problems.html