Windows 10 / 11 post WU installation cleanup script


Hey, folks,

Thanks to a lot of wonderful folks here, we've made mention in a previous Insider topic about cleanup steps that can be run after Windows Update performs a major version install.

Though these have been mentioned before by many, many people, it was this post by @IanMosley that started me on implementing this as an step to clean up both my main Windows installation and all the VMs I have for testing:


A few posts later, @geneo offered some good advice on how to streamline that set of commands in this post:


Which, eventually, led me to mentioning that I had put them all in a batch file to run after major WU installs:


Thus far I've just been right clicking the file and selecting Run as Administrator to run it - not all that hard. But, today, I went in search of a self-elevation script for batch files so I can just double click the file and let it do its thing.

I found a good thread at Stack Overflow that has a few methods mentioned, including direct self-elevation, elevation via WSH, via VBScripting, and even via Powershell. I tested several ones, and found that this particular script works best and is no nonsense and has no fuss:


I've also added a pause command at the end so that the window remains on screen after completing so you can see the results, and a simple keypress will close it out.

So, here is the code as I'm using it now:

Batch:
:: Elevation script from StackOverflow
:: https://stackoverflow.com/a/28467343

:: Begin Elevation script

@ECHO OFF
setlocal EnableDelayedExpansion

::net file to test privileges, 1>NUL redirects output, 2>NUL redirects errors
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"

::Add quotes to the batch path, if needed
set "script=%0"
set script=%script:"=%
IF '%0'=='!script!' ( GOTO PathQuotesDone )
    set "batchPath=""%batchPath%"""
:PathQuotesDone

::Add quotes to the arguments, if needed.
: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 the vb script to elevate the batch file
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 the elevation tag and set the correct working directory
IF '%1'=='ELEV' ( shift /1 )
cd /d %~dp0

::Do your adminy thing here...

:: End Elevation Script
:: Begin cleanup script

start /B /wait rundll32.exe pnpclean.dll,RunDLL_PnpClean /drivers/maxclean
start /B /wait dism /Online /Cleanup-Image /CheckHealth
start /B /wait sfc /scannow
start /B /wait dism /Online /Cleanup-Image /RestoreHealth
start /B /wait dism /online /Cleanup-Image /Startcomponentcleanup /resetbase

pause

You can copy the contents and save it to a file with a .BAT extension and it should work just fine, tested across Windows 10 and Windows 10 Insider Preview, plus Windows 11 (RTM, Release Preview, Beta, Dev and Canary current builds).

If you'd rather just download the batch file, here you go.

Download

Enjoy!

P.S. - if you have any suggestions on improving it / adding more functionality / expanding the scope of the cleanup, feel free to comment below!
 
Windows Build/Version
Windows 10 / Windows 11

Attachments

Last edited by a moderator:
I was directed in one of my forum help posts to run this script. Can anyone tell me what it does? Either I am out of the loop, or I missed what the script is supposed to do.

Thanks, Jesse

It basically just runs these commands but automated and in succession, Jesse.

/drivers/maxclean
dism /Online /Cleanup-Image /CheckHealh
sfc /scannow
dism /Online /Cleanup-Image /RestoreHealth
dism /online /Cleanup-Image /Startcomponentcleanup /resetbase

So, to clarify a little more, the script I have linked in the first post is my attempt to collate all of the usual steps many of use power, pro and expert users here at Eleven FOrum (11F) use to help clean up our systems after a major update to Windows, specifically those line items that @antspants mentions. I did a lot of research and evaluated various ways to make the script more automated, and settled on a way that the batch file run and automatically elevated its own privileges so the commands can be run without unnecessary (and repeated) UAC elevation prompts, or potentially failing because of a lack of elevation in the first place.

In post #47 (<-- clickable link) above, though, I link to a utility that can run all of these commands with a bit more clarity, giving a small explanation of each, and while less automated than my script, it is, I feel, the superior approach to accomplishing these same steps that my script does, partially because of the independent windows with respective command output, as well as the ability to run other commands that are not included in the script that I compiled.

Your approach is probably the best way!

I removed another app called web experience something or other. It apparently controls the widget stuff which I don't use. Bofore the day was out, I noticed that windows had re-installed it.

I'm beginning to think this particular minion function really isn't useful.

I suppose it depends on the approach - but removing pre-installed Windows app does require a bit of research. As Garlin noted in post #54 above, one such example is one app the was renamed and a new app that was added using the old name lol. Whereas the old app was removable, the newer one is not, and you noted that it still showed up even after you tagged it for removal - quite possibly because Stefan's utility was still trying to remove the old one versus the new one.

I've played around in the part with removing things, but I've found that simply disabling most of them suffices for me, and it's a lot less hassle in the long run, particularly when

1. I tend to cleanly install Windows 2-3 times a year, and
2. Windows can pull things like the above-noted app rename and replace, potentially rendering pre-written scripts (at least partially) useless, unless you are made aware of such changes in newer builds and adjust accordingly.

It's already so much of a headache to maintain such a script because of that second point, and since I run multiple VMs of various Windows 10 and Windows 11 versions, I've resorted to using Stefan's utility for everything my script can do and basically nothing else.
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 Current build
    Computer type
    PC/Desktop
    Manufacturer/Model
    HomeBrew
    CPU
    AMD Ryzen 9 3950X
    Motherboard
    MSI MEG X570 GODLIKE
    Memory
    4 * 32 GB - Corsair Vengeance 3600 MHz
    Graphics Card(s)
    EVGA GeForce RTX 3080 Ti XC3 ULTRA GAMING (12G-P5-3955-KR)
    Sound Card
    Realtek® ALC1220 Codec
    Monitor(s) Displays
    2x Eve Spectrum ES07D03 4K Gaming Monitor (Matte) | Eve Spectrum ES07DC9 4K Gaming Monitor (Glossy)
    Screen Resolution
    3x 3840 x 2160
    Hard Drives
    3x Samsung 980 Pro NVMe PCIe 4 M.2 2 TB SSD (MZ-V8P2T0B/AM) } 3x Sabrent Rocket NVMe 4.0 1 TB SSD (USB)
    PSU
    PC Power & Cooling’s Silencer Series 1050 Watt, 80 Plus Platinum
    Case
    Fractal Design Define 7 XL Dark ATX Full Tower Case
    Cooling
    Arctic Liquid Freezer III 420 RGB + Air 3x 140mm case fans (pull front) + 1x 120 mm (push back) and 1 x 120 mm (pull bottom)
    Keyboard
    SteelSeries Apex Pro Wired Gaming Keyboard
    Mouse
    Logitech MX Master 3S | MX Master 3 for Business
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
    Browser
    Nightly (default) + Firefox (stable), Chrome, Edge , Arc
    Antivirus
    Defender + MB 5 Beta
  • Operating System
    ChromeOS Flex Dev Channel (current)
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E5470
    CPU
    Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
    Motherboard
    Dell
    Memory
    16 GB
    Graphics card(s)
    Intel(R) HD Graphics 520
    Sound Card
    Intel(R) HD Graphics 520 + RealTek Audio
    Monitor(s) Displays
    Dell laptop display 15"
    Screen Resolution
    1920 * 1080
    Hard Drives
    Toshiba 128GB M.2 22300 drive
    INTEL Cherryville 520 Series SSDSC2CW180A 180 GB SATA III SSD
    PSU
    Dell
    Case
    Dell
    Cooling
    Dell
    Mouse
    Logitech MX Master 3S (shared w. Sys 1) | Dell TouchPad
    Keyboard
    Dell
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
Just some input about the script:

1) rundll32.exe pnpclean.dll,RunDLL_PnpClean /drivers/maxclean
which when I did a search to figure out what it does before reading beyond the post #1, it can have bad consequences as seen here:

2) dism /online /Cleanup-Image /Startcomponentcleanup /resetbase

A few days ago when I had the Error 6824, I was reading about /resetbase and according to post #2 in this thread:
/resetbase has been disabled and it does more harm than good but /resetbase is ignored regardless.
Comment #26 in the current thread actually tells what /resetbase does in the "Warning" section.
 

My Computer

System One

  • OS
    Windows XP/7/8/8.1/10/11, Linux, Android, FreeBSD Unix
    Computer type
    Laptop
    Manufacturer/Model
    Dell XPS 15 9570
    CPU
    Intel® Core™ i7-8750H 8th Gen 2.2Ghz up to 4.1Ghz
    Motherboard
    Dell XPS 15 9570
    Memory
    64GB using 2x32GB CL16 Mushkin redLine modules
    Graphics Card(s)
    Intel UHD 630 & NVIDIA GeForce GTX 1050 Ti with 4GB DDR5
    Sound Card
    Realtek ALC3266-CG
    Monitor(s) Displays
    15.6" 4K Touch UltraHD 3840x2160 made by Sharp
    Screen Resolution
    3840x2160
    Hard Drives
    Toshiba KXG60ZNV1T02 NVMe 1TB SSD
    PSU
    Dell XPS 15 9570
    Case
    Dell XPS 15 9570
    Cooling
    Stock
    Keyboard
    Stock
    Mouse
    SwitftPoint ProPoint
    Internet Speed
    Comcast/XFinity 1.44Gbps/42.5Mbps
    Browser
    Microsoft EDGE (Chromium based) & Google Chrome
    Antivirus
    Windows Defender that came with Windows
I downloaded your script, but at this line in the script, dism /online /Cleanup-Image /Startcomponentcleanup /resetbase, I get this error at 23%:
Error: 6824 - The operation cannot be performed because another transaction depends on this property not changing.
What to do??
That has nothing to do with the script or the build of Windows you are running as others had mentioned when responding to you and also, /resetbase has nothing to do with it as it's ignored and disabled by Windows .

I had the same issue two days ago and the solution is mentioned in my post here with full credits to @Bree who along with others experienced the same problem over a year ago:
 
Last edited:

My Computer

System One

  • OS
    Windows XP/7/8/8.1/10/11, Linux, Android, FreeBSD Unix
    Computer type
    Laptop
    Manufacturer/Model
    Dell XPS 15 9570
    CPU
    Intel® Core™ i7-8750H 8th Gen 2.2Ghz up to 4.1Ghz
    Motherboard
    Dell XPS 15 9570
    Memory
    64GB using 2x32GB CL16 Mushkin redLine modules
    Graphics Card(s)
    Intel UHD 630 & NVIDIA GeForce GTX 1050 Ti with 4GB DDR5
    Sound Card
    Realtek ALC3266-CG
    Monitor(s) Displays
    15.6" 4K Touch UltraHD 3840x2160 made by Sharp
    Screen Resolution
    3840x2160
    Hard Drives
    Toshiba KXG60ZNV1T02 NVMe 1TB SSD
    PSU
    Dell XPS 15 9570
    Case
    Dell XPS 15 9570
    Cooling
    Stock
    Keyboard
    Stock
    Mouse
    SwitftPoint ProPoint
    Internet Speed
    Comcast/XFinity 1.44Gbps/42.5Mbps
    Browser
    Microsoft EDGE (Chromium based) & Google Chrome
    Antivirus
    Windows Defender that came with Windows
Is it a good idea/recommended to run this after the update to 24H2 from 23H2 ? And if it is, should I be running all of the commands or ?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Myself
    CPU
    AMD 7950X3D
    Motherboard
    Asus ROG Crosshair X670E Gene
    Memory
    G.Skill Z5 Neo RGB 2x32GB @ 6000CL26 (F5-6000J2636G32GX2-TZ5NR)
    Graphics Card(s)
    MSI 4090 Gaming X Slim
    Monitor(s) Displays
    Dell Alienware AW3423DW
    Screen Resolution
    3440x1440
    Hard Drives
    1 x Samsung 990 Pro 2TB
    2 x Samsung 990 Pro 4TB
    1 x Samsung 870 QVO 8TB
    PSU
    Corsair SF1000
    Case
    Sliger Cerberus
    Cooling
    Noctua NH-D12L
    Keyboard
    Wooting Two HE
    Mouse
    Logitech G Pro Wireless
    Internet Speed
    1.6Gbps
    Browser
    DuckDuckGo
    Antivirus
    Kaspersky Premium
    Other Info
    Speakers: SoundBlaster Katana X v2
    Headphones: Audeze LCD-GX & AIAIAI TMA-2 Wireless+
    Camera: Logitech Brio
    Drawing Tablet: Wacom Intuos Pro M
    NAS: WD MyCloud
    Onboard WiFi/BT: Qualcomm NCM865 WiFi 7
  • Operating System
    Windows 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Myself
    CPU
    AMD 5950X
    Motherboard
    Asus ROG Crosshair VIII Impact
    Graphics card(s)
    PNY GeForce RTX 3090 24GB XLR8 Gaming
    Monitor(s) Displays
    Asus ROG Swift PG35VQ
    Screen Resolution
    3440x1440
    Hard Drives
    Samsung 980 Pro 2TB
    PSU
    Corsair SF750
    Case
    Ncase M1 v6
    Cooling
    Custom loop
    Mouse
    Logitech G Pro Wireless
    Keyboard
    Wooting One
    Internet Speed
    1.6Gbps
    Antivirus
    Kapsersky Premium
    Other Info
    Soundblaster Katana X
Is it a good idea/recommended to run this after the update to 24H2 from 23H2 ? And if it is, should I be running all of the commands or ?

I run Virtual Machines of numerous Windows 11 builds, mostly the various Insider Preview builds, but I do have one bone stock Windows 11 23H2 VM and another Windows 11 24H2 bone stock VM.

I run this script (mainly through the app I mentioned in post #47) on all of them. it's caught a few issues here and there along the way, early on, so for that reason alone I highly suggest doing this every time there is a massive update like changing the build version (23H2 --> 24H2) but even when there are simple build version changes (26100.2859 --> 26100.3025, as an example).

So, long story short - yes, it is always worth it to run these steps. I even run them on my main machine that is running 24H2.

Since you're asking specifically for the major update, it really is worth your while to run all of the steps.

@Almighty1 mentions a few posts up that the driver cleaning might cause issues, and resetbase has been ... relegated to being ignored.

So, these are the commands you'll want.

Batch:
dism /Online /Cleanup-Image /CheckHealth
dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow

Technically, you don't even need to run the first one, so these two should be good enough:

Batch:
dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow
 

My Computers

System One System Two

  • OS
    Windows 11 23H2 Current build
    Computer type
    PC/Desktop
    Manufacturer/Model
    HomeBrew
    CPU
    AMD Ryzen 9 3950X
    Motherboard
    MSI MEG X570 GODLIKE
    Memory
    4 * 32 GB - Corsair Vengeance 3600 MHz
    Graphics Card(s)
    EVGA GeForce RTX 3080 Ti XC3 ULTRA GAMING (12G-P5-3955-KR)
    Sound Card
    Realtek® ALC1220 Codec
    Monitor(s) Displays
    2x Eve Spectrum ES07D03 4K Gaming Monitor (Matte) | Eve Spectrum ES07DC9 4K Gaming Monitor (Glossy)
    Screen Resolution
    3x 3840 x 2160
    Hard Drives
    3x Samsung 980 Pro NVMe PCIe 4 M.2 2 TB SSD (MZ-V8P2T0B/AM) } 3x Sabrent Rocket NVMe 4.0 1 TB SSD (USB)
    PSU
    PC Power & Cooling’s Silencer Series 1050 Watt, 80 Plus Platinum
    Case
    Fractal Design Define 7 XL Dark ATX Full Tower Case
    Cooling
    Arctic Liquid Freezer III 420 RGB + Air 3x 140mm case fans (pull front) + 1x 120 mm (push back) and 1 x 120 mm (pull bottom)
    Keyboard
    SteelSeries Apex Pro Wired Gaming Keyboard
    Mouse
    Logitech MX Master 3S | MX Master 3 for Business
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
    Browser
    Nightly (default) + Firefox (stable), Chrome, Edge , Arc
    Antivirus
    Defender + MB 5 Beta
  • Operating System
    ChromeOS Flex Dev Channel (current)
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude E5470
    CPU
    Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
    Motherboard
    Dell
    Memory
    16 GB
    Graphics card(s)
    Intel(R) HD Graphics 520
    Sound Card
    Intel(R) HD Graphics 520 + RealTek Audio
    Monitor(s) Displays
    Dell laptop display 15"
    Screen Resolution
    1920 * 1080
    Hard Drives
    Toshiba 128GB M.2 22300 drive
    INTEL Cherryville 520 Series SSDSC2CW180A 180 GB SATA III SSD
    PSU
    Dell
    Case
    Dell
    Cooling
    Dell
    Mouse
    Logitech MX Master 3S (shared w. Sys 1) | Dell TouchPad
    Keyboard
    Dell
    Internet Speed
    AT&T LightSpeed Gigabit Duplex Ftth
In what order do members here use these?

scanhealth
CheckHealth
RestoreHealth

AnalyzeComponentStore
StartComponentCleanup
Startcomponentcleanup /resetbase

It’s annoying to me that there are so many opinions on the web that conflict. depending on who or what you’re reading.

I've been playing with the original script in post one.
Should any of the commands I have asked to be excluded, not have been excluded (skipped)?

The script I have created is as follows:

✅ If DISM ScanHealth found no errors. CheckHealth and RestoreHealth will be skipped with Popup notification.
✅ If AnalyzeComponentStore found no issues. StartComponentCleanup and resetbase will be skipped with Popup notification.
✅ Filtered output – only meaningful results from each command will be saved in the log file, instead of entire execution logs.
✅ Script runs properly – added error checking while ensuring steps don’t stop execution when skipping sections.
✅ Log file auto-opens in Notepad at the end of script process for easy review.


Batch:
:: Elevation script from StackOverflow :: https://stackoverflow.com/a/28467343
:: Begin Elevation script
@ECHO OFF
setlocal EnableDelayedExpansion
set "logfile=%temp%\cleanup_log.txt"
echo Cleanup Process Log > "%logfile%"
echo =================== >> "%logfile%"

:: net file to test privileges
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"

:: Add quotes to the batch path, if needed
set "script=%0"
set script=%script:"=%
IF '%0'=='!script!' ( GOTO PathQuotesDone )
    set "batchPath=""%batchPath%"""
:PathQuotesDone

:: Add quotes to the arguments, if needed
: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 the VB script to elevate the batch file
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 the elevation tag and set the correct working directory
IF '%1'=='ELEV' ( shift /1 )
cd /d %~dp0

:: Cleanup script

echo Running PnpClean... >> "%logfile%"
start /B /wait rundll32.exe pnpclean.dll,RunDLL_PnpClean /drivers/maxclean | find /i "completed" >> "%logfile%"

echo Running DISM ScanHealth... >> "%logfile%"
start /B /wait dism /online /cleanup-image /scanhealth | find /i "completed successfully" >> "%logfile%"

:: Check ScanHealth results before proceeding
IF %ERRORLEVEL% NEQ 0 (
    echo Errors found! Running further checks... >> "%logfile%"
    start /B /wait dism /Online /Cleanup-Image /CheckHealth | find /i "corruption detected" >> "%logfile%"
    start /B /wait dism /Online /Cleanup-Image /RestoreHealth | find /i "completed successfully" >> "%logfile%"
) ELSE (
    echo No errors found. Skipping CheckHealth and RestoreHealth. >> "%logfile%"
    msg * "DISM ScanHealth found no errors. CheckHealth and RestoreHealth have been skipped."
)

:: Continue execution
echo Running SFC Scan... >> "%logfile%"
start /B /wait sfc /scannow | find /i "did not find any integrity violations" >> "%logfile%"

echo Running Component Store Analysis... >> "%logfile%"
start /B /wait Dism /Online /Cleanup-Image /AnalyzeComponentStore | find /i "recommend you clean up" >> "%logfile%"

:: Check AnalyzeComponentStore results before proceeding
IF %ERRORLEVEL% NEQ 0 (
    echo Component store cleanup is required. Running cleanup... >> "%logfile%"
    start /B /wait DISM /online /Cleanup-Image /StartComponentCleanup | find /i "completed successfully" >> "%logfile%"
    start /B /wait dism /online /Cleanup-Image /Startcomponentcleanup /resetbase | find /i "completed successfully" >> "%logfile%"
) ELSE (
    echo Component store is healthy. Skipping StartComponentCleanup and resetbase. >> "%logfile%"
    msg * "AnalyzeComponentStore found no issues. StartComponentCleanup and resetbase have been skipped."
)

:: Ensure script execution continues
echo Cleanup process completed successfully. >> "%logfile%"
echo Opening log file... >> "%logfile%"

:: Open log file in Notepad
start notepad "%logfile%"

pause

The output log file needs work.
 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5039
    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.
Also, it no longer executes without prompt for permissions, which is annoying. (Elevation script)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5039
    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.
If DISM ScanHealth found no errors. CheckHealth and RestoreHealth will be skipped with Popup message

I setup something similar to this for Intune environments (cloud-based device management tool from MSFT).

CheckHealth is very fast, because it merely checks to see if the image has already been flagged as unhealthy by some other process. CheckHealth doesn't do any scanning on its own. So, I run CheckHealth first. If CheckHealth already knows there's corruption, then I can go straight to RestoreHealth.

If CheckHealth doesn't report corruption, well, there still may be corruption, so then I run a ScanHealth. If ScanHealth says corruption, then I RestoreHealth.

Now admittedly, the reason it's done this way for Intune is for reporting. I can see which machines had no issues, and which machines had issues, and which of those were successfully repaired. On a home PC, you probably don't care about that; just fix the problem.
 

My Computer

System One

  • OS
    Windows 11 Pro 24H2 [rev. 4061]
    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
I setup something similar to this for Intune environments (cloud-based device management tool from MSFT).

CheckHealth is very fast, because it merely checks to see if the image has already been flagged as unhealthy by some other process. CheckHealth doesn't do any scanning on its own. So, I run CheckHealth first. If CheckHealth already knows there's corruption, then I can go straight to RestoreHealth.

If CheckHealth doesn't report corruption, well, there still may be corruption, so then I run a ScanHealth. If ScanHealth says corruption, then I RestoreHealth.

Now admittedly, the reason it's done this way for Intune is for reporting. I can see which machines had no issues, and which machines had issues, and which of those were successfully repaired. On a home PC, you probably don't care about that; just fix the problem.

Good to know and very helpful, thank you 🙏
Will adjust my script, slowly.

I actually just now created a GitHub Ai account. I am interested in seeing how it works
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5039
    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.
A common mistake is DO NOT RUN DISM /ResetBase unless you're confident the latest installed Monthly Update is stable. The reason there's "leftover" files is to allow Windows to roll back a bad update without restoring your PC from a previous backup. Once you run /ResetBase, you can be stuck with a broken Windows until (hopefully) MS fixes the problem in a future update.

A repair reinstall won't fix it because you need to install a lower build of Windows to undo the last update, and a newer build on disk voids the repair.

This should never be an "automatic" task except on a brand new Windows install. If you're in a habit of manually controlling when WU is allowed to install updates, and have a good idea of how long it takes to discover new problems, then it's safe to use. Otherwise, don't do it right after the Monthly Update is installed.
 

My Computer

System One

  • OS
    Windows 7
A common mistake is DO NOT RUN DISM /ResetBase unless you're confident the latest installed Monthly Update is stable.

Thanks, I did wonder about that.
Having said that, I am pretty diligent with my backup images.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.5039
    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.
A common mistake is DO NOT RUN DISM /ResetBase unless you're confident the latest installed Monthly Update is stable. The reason there's "leftover" files is to allow Windows to roll back a bad update without restoring your PC from a previous backup. Once you run /ResetBase, you can be stuck with a broken Windows until (hopefully) MS fixes the problem in a future update.

I thought the reset base option was disabled in recent windows versions so that it runs the same as a plain cleanup command.

I think I remember seeing that in the registry too, but it's been a long time.
 

My Computer

System One

  • OS
    win 11 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell 790 (Mt)
    CPU
    i5-2400
    Motherboard
    Dell
    Memory
    32 GB DDR-3
    Graphics Card(s)
    Intel HD Graphics 2000 (on-board)
    Sound Card
    Intel Cougar Point PCH [B2] (On-Board)
    Monitor(s) Displays
    LG 27MN60T
That's true, /ResetBase is cheating. In many cases, it's actually delta compressing the older files and not fully removing them. This is done to preserve full WinSxS compatibility with any future Updates you may want to install. There's a balance of recovering more space vs. the risk of breaking Windows.

Yes, you can use the two known reg keys and fully remove more superseded components, but that should be reserved for very experienced users since it can break DISM.
 

My Computer

System One

  • OS
    Windows 7
I think I'll stick to the basic repair options. :-) I do like the idea of CheckHealth first to save time.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2, Build 26100.4202, 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.4202, 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

Latest Support Threads

Back
Top Bottom