powershell - Windows Update Cleanup in Registry Editor -


in disk cleanup tool there option windows update cleanup. if i'm wanting set through following method located in registry?

set-itemproperty -path 'hklm:\software\microsoft\windows\currentversion\explorer\volumecaches\temporary files' -name stateflags0012 -type dword -value 2 

if /sageset:# see option set windows update cleanup, i've been unable find in regedit.

you list of available volumecaches , set stateflag with:

# create reg keys $stateflags= "stateflags0099" $volcaches = gci "hklm:\software\microsoft\windows\currentversion\explorer\volumecaches" foreach($vc in $volcaches) {     new-itemproperty -path "$($vc.pspath)" -name $stateflags -value 2 -type dword -force | out-null } 

but have no control include in cleanup. script may edit (shorten) list individually.

#requires -runasadministrator  $sageset = "stateflags0099" $base = "hklm:\software\microsoft\windows\currentversion\explorer\volumecaches\" $locations= @(     "active setup temp folders"     "branchcache"     "downloaded program files"     "gamenewsfiles"     "gamestatisticsfiles"     "gameupdatefiles"     "internet cache files"     "memory dump files"     "offline pages files"     "old chkdsk files"     "previous installations"     "recycle bin"     "service pack cleanup"     "setup log files"     "system error memory dump files"     "system error minidump files"     "temporary files"     "temporary setup files"     "temporary sync files"     "thumbnail cache"     "update cleanup"     "upgrade discarded files"     "user file versions"     "windows defender"     "windows error reporting archive files"     "windows error reporting queue files"     "windows error reporting system archive files"     "windows error reporting system queue files"     "windows esd installation files"     "windows upgrade log files" )  foreach($location in $locations) {     set-itemproperty -path $($base+$location) -name $sageset -type dword -value 2 -ea silentlycontinue | out-null }  # cleanup . have convert sageset number $args = "/sagerun:$([string]([int]$sageset.substring($sageset.length-4)))" start-process -wait "$env:systemroot\system32\cleanmgr.exe" -argumentlist $args -windowstyle hidden  # removw stateflags foreach($location in $locations) {     remove-itemproperty -path $($base+$location) -name $sageset -force -ea silentlycontinue | out-null } 

hope helps


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -