Solved Question regarding sfc and dism and System Performance


I mentioned in the beginning of the thread, SFC should really be used last.
If you’re still interested in a batch file, I can remove SFC from the beginning and leave it for last

Could you do that please.

Microsoft doesn't mention using checkhealth only restorehealth

any reason for not checking before running restore?
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Intel Core i5-12600K 3.7 GHz 10-Core Processor
    Motherboard
    Gigabyte B760M H DDR4 Micro ATX LGA1700 Motherboard
    Memory
    Corsair Vengeance LPX 64 GB (2 x 32 GB) DDR4-3200 CL16 Memory
    Graphics Card(s)
    Integrated Intel UHD Graphics 770
    Sound Card
    Realtek
    Monitor(s) Displays
    LG
    Hard Drives
    Samsung 990 Pro 1 TB M.2-2280 PCIe 4.0 X4 NVME Solid State Drive
    Western Digital Blue 2 TB 3.5" 7200 RPM Internal Hard Drive
    PSU
    Silverstone ATTIS 650R 650 W 80+ Bronze Certified ATX Power Supply
    Case
    Thermaltake Versa H25 ATX Mid Tower Case
    Cooling
    CPU Cooler Thermalright Assassin Spirit 120 EVO ARGB (RGB Disabled) - Case Fans BlackThermalright TL-C12C-S X3 66.17 CFM 120 mm Fans 3-Pack (RGB disabled)
    Internet Speed
    1 Gbps
    Other Info
    I hate RGB.

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.
This will run the commands and inform you that the commands were run (with a status message)
Open a log file at the end for confirmation.

  • dism check health
  • dism scan health
  • dism restore health (if needed)
  • sfc /scannow


  • It
    • Elevates privileges using VBScript if the script isn't already running as administrator.
    • Sets up logging to record all actions, successes, failures, and skipped commands in %temp%\script_log.txt.
    • Runs dism /Online /Cleanup-Image /CheckHealth to determine if there are any system integrity issues.
    • Conditionally runs dism /Online /Cleanup-Image /RestoreHealth only if corruption is found.
    • Logs and displays skipped commands (e.g., RestoreHealth if no corruption is detected).
    • Executes sfc /scannow at the end to scan and repair system files.
    • Logs success or failure messages for every command executed.
    • Opens the log file automatically in Notepad after execution for easy review.
    • Pauses execution at the end, allowing the user to review the command window before it closes.
Content of batch file:

Code:
@ECHO OFF
setlocal EnableDelayedExpansion

:: Elevation check
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto START ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' ( goto START )

set "batchPath=%~f0"
set "batchArgs=ELEV"
set "script=%0"
set script=%script:"=%

IF '%0'=='!script!' ( GOTO PathQuotesDone )
    set "batchPath=""%batchPath%"""
:PathQuotesDone

:ArgLoop
IF '%1'=='' ( GOTO EndArgLoop ) else ( GOTO AddArg )
:AddArg
    set "arg=%1"
    set arg=%arg:"=%
    IF '%1'=='!arg!' ( GOTO NoQuotes )
        set "batchArgs=%batchArgs% "%1""
        GOTO QuotesDone
    :NoQuotes
        set "batchArgs=%batchArgs% %1"
:QuotesDone
    shift
    GOTO ArgLoop
:EndArgLoop

:: Create and run VBScript for elevation
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "cmd", "/c ""!batchPath! !batchArgs!""", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B

:START
:: Remove elevation flag and set working directory
IF '%1'=='ELEV' ( shift /1 )
cd /d %~dp0

:: Begin cleanup script with logging
set "logFile=%temp%\script_log.txt"
echo Cleanup process started: %DATE% %TIME% > "%logFile%"
echo Cleanup process started: %DATE% %TIME%

call :RunCommand "dism /Online /Cleanup-Image /CheckHealth"
call :RunCommand "dism /Online /Cleanup-Image /ScanHealth"

if %errorlevel% NEQ 0 (
    echo Issues detected in Windows image, running RestoreHealth... >> "%logFile%"
    echo Issues detected in Windows image, running RestoreHealth...
    call :RunCommand "dism /Online /Cleanup-Image /RestoreHealth"
) else (
    echo No corruption found, skipping RestoreHealth. >> "%logFile%"
    echo No corruption found, skipping RestoreHealth.
    echo SKIPPED: dism /Online /Cleanup-Image /RestoreHealth >> "%logFile%"
    echo SKIPPED: dism /Online /Cleanup-Image /RestoreHealth
)

:: Run SFC only once at the end
call :RunCommand "sfc /scannow"

echo Cleanup completed successfully: %DATE% %TIME% >> "%logFile%"
echo Cleanup completed successfully: %DATE% %TIME%

:: Open log file at the end
start notepad "%logFile%"

pause
exit /B

:RunCommand
echo Running: %~1
%~1
if %errorlevel% EQU 0 (
    echo %~1 Completed successfully. >> "%logFile%"
    echo %~1 Completed successfully.
) else (
    echo ERROR: %~1 failed with error level %errorlevel% >> "%logFile%"
    echo ERROR: %~1 failed with error level %errorlevel%.
)
exit /B

If you don't want the log file to open at the end, say so (y)

Log file confirmation on completion will look like this (in Notepad):

Cleanup process started: Sun 15/06/2025 7:28:41.48
dism /Online /Cleanup-Image /CheckHealth Completed successfully.
No corruption found, skipping RestoreHealth.
SKIPPED: dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow Completed successfully.
Cleanup completed successfully: Sun 15/06/2025 7:37:31.35

Command window looks like this on completion:

Cleanup process started: Sun 15/06/2025 7:28:41.49
Running: dism /Online /Cleanup-Image /CheckHealth

Deployment Image Servicing and Management tool
Version: 10.0.22621.2792

Image Version: 10.0.22631.5472

No component store corruption detected.
The operation completed successfully.
dism /Online /Cleanup-Image /CheckHealth Completed successfully.
No corruption found, skipping RestoreHealth.
SKIPPED: dism /Online /Cleanup-Image /RestoreHealth
Running: 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.
sfc /scannow Completed successfully.
Cleanup completed successfully: Sun 15/06/2025 7:37:31.35
Press any key to continue . . .
 

Attachments

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.
This will run the commands and inform you that the commands were run (with a status message)
Open a log file at the end for confirmation.

  • dism check health
  • dism scan health
  • dism restore health (if needed)
  • sfc /scannow


  • It
    • Elevates privileges using VBScript if the script isn't already running as administrator.
    • Sets up logging to record all actions, successes, failures, and skipped commands in %temp%\script_log.txt.
    • Runs dism /Online /Cleanup-Image /CheckHealth to determine if there are any system integrity issues.
    • Conditionally runs dism /Online /Cleanup-Image /RestoreHealth only if corruption is found.
    • Logs and displays skipped commands (e.g., RestoreHealth if no corruption is detected).
    • Executes sfc /scannow at the end to scan and repair system files.
    • Logs success or failure messages for every command executed.
    • Opens the log file automatically in Notepad after execution for easy review.
    • Pauses execution at the end, allowing the user to review the command window before it closes.
Content of batch file:

Code:
@ECHO OFF
setlocal EnableDelayedExpansion

:: Elevation check
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto START ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' ( goto START )

set "batchPath=%~f0"
set "batchArgs=ELEV"
set "script=%0"
set script=%script:"=%

IF '%0'=='!script!' ( GOTO PathQuotesDone )
    set "batchPath=""%batchPath%"""
:PathQuotesDone

:ArgLoop
IF '%1'=='' ( GOTO EndArgLoop ) else ( GOTO AddArg )
:AddArg
    set "arg=%1"
    set arg=%arg:"=%
    IF '%1'=='!arg!' ( GOTO NoQuotes )
        set "batchArgs=%batchArgs% "%1""
        GOTO QuotesDone
    :NoQuotes
        set "batchArgs=%batchArgs% %1"
:QuotesDone
    shift
    GOTO ArgLoop
:EndArgLoop

:: Create and run VBScript for elevation
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "cmd", "/c ""!batchPath! !batchArgs!""", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B

:START
:: Remove elevation flag and set working directory
IF '%1'=='ELEV' ( shift /1 )
cd /d %~dp0

:: Begin cleanup script with logging
set "logFile=%temp%\script_log.txt"
echo Cleanup process started: %DATE% %TIME% > "%logFile%"
echo Cleanup process started: %DATE% %TIME%

call :RunCommand "dism /Online /Cleanup-Image /CheckHealth"
if %errorlevel% NEQ 0 (
    echo Issues detected in Windows image, running RestoreHealth... >> "%logFile%"
    echo Issues detected in Windows image, running RestoreHealth...
    call :RunCommand "dism /Online /Cleanup-Image /RestoreHealth"
) else (
    echo No corruption found, skipping RestoreHealth. >> "%logFile%"
    echo No corruption found, skipping RestoreHealth.
    echo SKIPPED: dism /Online /Cleanup-Image /RestoreHealth >> "%logFile%"
    echo SKIPPED: dism /Online /Cleanup-Image /RestoreHealth
)

:: Run SFC only once at the end
call :RunCommand "sfc /scannow"

echo Cleanup completed successfully: %DATE% %TIME% >> "%logFile%"
echo Cleanup completed successfully: %DATE% %TIME%

:: Open log file at the end
start notepad "%logFile%"

pause
exit /B

:RunCommand
echo Running: %~1
%~1
if %errorlevel% EQU 0 (
    echo %~1 Completed successfully. >> "%logFile%"
    echo %~1 Completed successfully.
) else (
    echo ERROR: %~1 failed with error level %errorlevel% >> "%logFile%"
    echo ERROR: %~1 failed with error level %errorlevel%.
)
exit /B

If you don't want the log file to open at the end, say so (y)

Log file confirmation on completion will look like this:



Command window looks like this on completion:

Thank you so much once again. :)
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Intel Core i5-12600K 3.7 GHz 10-Core Processor
    Motherboard
    Gigabyte B760M H DDR4 Micro ATX LGA1700 Motherboard
    Memory
    Corsair Vengeance LPX 64 GB (2 x 32 GB) DDR4-3200 CL16 Memory
    Graphics Card(s)
    Integrated Intel UHD Graphics 770
    Sound Card
    Realtek
    Monitor(s) Displays
    LG
    Hard Drives
    Samsung 990 Pro 1 TB M.2-2280 PCIe 4.0 X4 NVME Solid State Drive
    Western Digital Blue 2 TB 3.5" 7200 RPM Internal Hard Drive
    PSU
    Silverstone ATTIS 650R 650 W 80+ Bronze Certified ATX Power Supply
    Case
    Thermaltake Versa H25 ATX Mid Tower Case
    Cooling
    CPU Cooler Thermalright Assassin Spirit 120 EVO ARGB (RGB Disabled) - Case Fans BlackThermalright TL-C12C-S X3 66.17 CFM 120 mm Fans 3-Pack (RGB disabled)
    Internet Speed
    1 Gbps
    Other Info
    I hate RGB.
Sorry... so sorry. had to tweak it. Could you download it again? It wasn't running scanhealth

  • ScanHealth added—provides a deeper scan for corruption before deciding whether to run RestoreHealth.
  • Improved accuracy—RestoreHealth now only runs if both CheckHealth and ScanHealth detect issues.
  • Complete visibility—you’ll see skipped, successful, or failed commands in both the log file and the command window.
  • Automatic log file opening—you get immediate access to all execution details when the script finishes
 

Attachments

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.
Do we really believe Microsoft?
They do make the operating system. 🤷🏻‍♂️
Microsoft doesn't mention using checkhealth only restorehealth

any reason for not checking before running restore?
CheckHealth reports the result of the last time a scan was done - the result of the last ScanHealth or RestoreHealth. If you’re just going to run ScanHealth or RestoreHealth immediately, you can skip the CheckHealth. Although, it takes almost no time, so no big loss.
 

My Computer

System One

  • OS
    Windows 11 Pro 24H2 [rev. 4351]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.4061
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Optiplex 7080
    CPU
    i9-10900 10 core 20 threads
    Motherboard
    DELL 0J37VM
    Memory
    32 gb
    Graphics Card(s)
    none-Intel UHD Graphics 630
    Sound Card
    Integrated Realtek
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    1tb Solidigm m.2 nvme+256gb SKHynix m.2 nvme /External drives 512gb Samsung m.2 sata+1tb Kingston m2.nvme+ 4gb Solidigm nvme
    PSU
    500w
    Case
    MT
    Cooling
    Dell Premium
    Keyboard
    Logitech wired
    Mouse
    Logitech wireless
    Internet Speed
    so slow I'm too embarrassed to tell
    Browser
    #1 Edge #2 Firefox
    Antivirus
    Defender+MWB Premium
  • Operating System
    Windows 11 Pro 24H2 26100.4061
    Computer type
    PC/Desktop
    Manufacturer/Model
    Beelink Mini PC SER5
    CPU
    AMD Ryzen 7 6800U
    Memory
    32 gb
    Graphics card(s)
    integrated
    Sound Card
    integrated
    Monitor(s) Displays
    Benq 27
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Crucial nvme
    Mouse
    Logitech wireless
    Keyboard
    Logitech wired
    Internet Speed
    still too embarrassed to tell
    Browser
    Firefox
    Antivirus
    Defender
    Other Info
    System 3 is non compliant Dell 9020 i7-4770/24gb ram Win11 PRO 26100.4061
Have you tested this script by doing intentional damage to your system?

1. By removing renaming \Windows\System32\devmgmt.msc or diskmgmt.msc, to trigger SFC?
2. By renaming one of the \Windows\WinSxS folders, to trigger DISM /restorehealth?
 

My Computer

System One

  • OS
    Windows 7
Thanks everyone.

I have all the information I need and yes I know we run Dism before SFC.

Cheers.
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Intel Core i5-12600K 3.7 GHz 10-Core Processor
    Motherboard
    Gigabyte B760M H DDR4 Micro ATX LGA1700 Motherboard
    Memory
    Corsair Vengeance LPX 64 GB (2 x 32 GB) DDR4-3200 CL16 Memory
    Graphics Card(s)
    Integrated Intel UHD Graphics 770
    Sound Card
    Realtek
    Monitor(s) Displays
    LG
    Hard Drives
    Samsung 990 Pro 1 TB M.2-2280 PCIe 4.0 X4 NVME Solid State Drive
    Western Digital Blue 2 TB 3.5" 7200 RPM Internal Hard Drive
    PSU
    Silverstone ATTIS 650R 650 W 80+ Bronze Certified ATX Power Supply
    Case
    Thermaltake Versa H25 ATX Mid Tower Case
    Cooling
    CPU Cooler Thermalright Assassin Spirit 120 EVO ARGB (RGB Disabled) - Case Fans BlackThermalright TL-C12C-S X3 66.17 CFM 120 mm Fans 3-Pack (RGB disabled)
    Internet Speed
    1 Gbps
    Other Info
    I hate RGB.
Have you tested this script by doing intentional damage to your system?

1. By removing renaming \Windows\System32\devmgmt.msc or diskmgmt.msc, to trigger SFC?
2. By renaming one of the \Windows\WinSxS folders, to trigger DISM /restorehealth?

Why don’t you show us all how it’s done, Maestro? I’m sure your effort would be appreciated.

As far as I am concerned, the script only does, in a batch, what the commands would do on their own. What’s to test?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.
Those two steps:
- Rename devmgmt.msc, so the file is "missing".
- Rename the last folder in \Windows\WinSxS with a different word in front of the folder name.

The point is the repair should restore what you just "broke".
 

My Computer

System One

  • OS
    Windows 7
Could you do that please.

Microsoft doesn't mention using checkhealth only restorehealth

any reason for not checking before running restore?
RestoreHealth has to check anyway, so it's a one-stop command. CheckHealth only checks the integrity flags as I recall, ScanHealth actually scans the image and reports any corruption.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2, Build 26100.4351, Experience Pack 1000.26100.107.0
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Brew
    CPU
    Intel Core i5 14500
    Motherboard
    Gigabyte B760M G P WIFI
    Memory
    64GB DDR4
    Graphics Card(s)
    GeForce RTX 4060
    Sound Card
    Chipset Realtek
    Monitor(s) Displays
    LG 45" Ultragear, Acer 24" 1080p
    Screen Resolution
    5120x1440, 1920x1080
    Hard Drives
    Crucial P310 2TB 2280 PCIe Gen4 3D NAND NVMe M.2 SSD (O/S)
    Silicon Power 2TB US75 Nvme PCIe Gen4 M.2 2280 SSD (backup)
    Crucial BX500 2TB 3D NAND (2nd backup)
    External off-line backup Drives: 2 NVMe 4TB drives in external enclosures
    PSU
    Thermaltake Toughpower GF3 750W
    Case
    LIAN LI LANCOOL 216 E-ATX PC Case
    Cooling
    Lots of fans!
    Keyboard
    Microsoft Comfort Curve 2000
    Mouse
    Logitech G305
    Internet Speed
    Verizon FiOS 1GB
    Browser
    Firefox
    Antivirus
    Malware Bytes & Windows Security
  • Operating System
    Windows 11 Pro 24H2, Build 26100.4351 Experience Pack 1000.26100.107.0
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Brew
    CPU
    Intel Core i5 14400
    Motherboard
    Gigabyte B760M DS3H AX
    Memory
    32GB DDR5
    Graphics card(s)
    Intel 700 Embedded GPU
    Sound Card
    Realtek Embedded
    Monitor(s) Displays
    27" HP 1080p
    Screen Resolution
    1920x1080
    Hard Drives
    Crucial P310 2TB 2280 PCIe Gen4 eD NAND PCIe SSD
    Samsung EVO 990 2TB NVMe Gen4 SSD
    Samsung 2TB SATA SSD
    PSU
    Thermaltake Smart BM3 650W
    Case
    Okinos Micro ATX Case
    Cooling
    Fans
    Mouse
    Logitech G305
    Keyboard
    Microsoft Comfort Curve 2000
    Internet Speed
    Verizon FiOS 1GB
    Browser
    Firefox
    Antivirus
    Malware Bytes & Windows Security
You could have a batch script to run them all for you, could even have it so it skips restorehealth of scanhealth finds nothing.
I just run DISM.exe /Online /Cleanup-image /Restorehealth after Microsoft release a newer build and once installed run SFC.exe /scannow
 

My Computer

System One

  • OS
    Windows 11 (latest version)
    Computer type
    PC/Desktop
    Manufacturer/Model
    home build
    CPU
    AMD Ryzen 3900
    Motherboard
    X570 AORUS Elite
    Memory
    64GB
    Graphics Card(s)
    RTX2070 SUPER
    Sound Card
    onboard
    Monitor(s) Displays
    iiyama XU2792QSU
    Screen Resolution
    2560 X 1440
    Hard Drives
    C drive 1TB SSD - D drive 8TB for 90% of my data - E Drive 4TB all photos Drives G and H for local backups - and a six bay NAS with 6 x 8TB for offline backups
    PSU
    be quiet 750W silver
    Case
    Tower Be Quiet
    Cooling
    Oil Radiator
    Keyboard
    Microsoft Biometrics
    Mouse
    Yes
    Internet Speed
    1Gb
    Browser
    various, librewolf, Vivaldi, Brave, DuckDuckGo
Those two steps:
- Rename devmgmt.msc, so the file is "missing".
- Rename the last folder in \Windows\WinSxS with a different word in front of the folder name.

The point is the repair should restore what you just "broke".

Sure mate, I get what you’re saying. But if there’s a break, the commands in the script should repair it, isn’t that what the commands are for? How would they normally proceed? The same as in the script I would imagine.

I will test as you mentioned, when I return from the Dr’s
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5472
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    5 x LG 25MS500-B - 1 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech: G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    1000/400Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Antivirus
    Defender / Malwarebytes
    Other Info
    …still on a horse.

Latest Support Threads

Back
Top Bottom