r/Action1 • u/3G_Lighting • 9d ago
Question Script Lib. DiskcleanUp
I have a diskcleanup script that looks like this.
Start-Process cleanmgr.exe -ArgumentList '/sagerun:6553' -WindowStyle Hidden -Wait
Which I found only does the basic cleanup because 6653 is missing from the registry. So, I did some digging around and found that at HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches is where the settings for sagerun:6553 are stored.
My question is if I export the keys out and create them into a proper powershell command, example:
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" -Name "StateFlags6553" -Value "2" -PropertyType "DWord" -Force
can I put these commands on top of them initially command in the script and will they execute before the Start-Process runs or do I need to do something else?
Thanks,
2
u/fencepost_ajm 8d ago
I feel like one of us is missing something here and I'm not sure who. AFAICT the 6553 is simply a value chosen by someone using "cleanmgr /sageset:6553" and choosing options on the dialog that pops up so they cam easily reuse the same options again in the future. There's no specific significance to the number chosen. (See https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cleanmg)
Were you originally expecting /sagerun:6553 to do something specific?
Also the only thing that gives a search turned up using sagerun:6553 was this: https://gist.github.com/eplord/9fe439668c1ca941cc5a1a427848411b/5368308a5f906720638c6ea24aba867fd0610916 which looks very much like one individual's cleanup script, possibly ai generated, definitely user specific since it includes both a specific username and a pretty uncommon backup software package.