/build/static/layout/Breadcrumb_cap_w.png

Cleanmgr sagerun with SCCM

I've a script which I run it independently on local machine with run as administrator it works perfectly!

but when I try to run the clean.bat on SCCM

it does not clean the disk clean files for some reason!


below is my script, seems like that " cleanmgr.exe /sagerun:911 " is not working properly, any idea how to fix it?


REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameNewsFiles" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameStatisticsFiles" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameUpdateFiles" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files" /f /v StateFlags0911 /t REG_DWORD /d 2 /REG:64


cleanmgr.exe /sagerun:911


REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameNewsFiles" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameStatisticsFiles" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameUpdateFiles" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files" /f /v StateFlags0911 /REG:64
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files" /f /v StateFlags0911 /REG:64

rd /s /q %windir%\temp\
mkdir %windir%\temp\








0 Comments   [ + ] Show comments

Answers (3)

Posted by: rileyz 8 years ago
Red Belt
1
You should just empty the Windows\Temp folder, not delete and recreate it.

Get PSExec and test test test! Use PSExec to run as SYSTEM context, as this is how sccm will run the above batch. I suspect SYSTEM context maybe causing the issue?

Comments:
  • Windows Temp is getting deleted without issue, the issue is only with SageRun - kabso5 8 years ago
Posted by: andys0123 8 years ago
Orange Senior Belt
1
Have you changed to 'Install Behaviour' of the Deployment Type to 'Install for System'? If still set to 'Install for User' it will not have permissions to set HKLM values.

Comments:
  • I've set the installation to be user interactive and using System, after the cleanmgr command, I've set a "PAUSE" and checked the HKLM Regs, the values are sat! , the issue is cleanmgr is only displaying a progress bar without cleaning the disk - kabso5 8 years ago
Posted by: thohun 5 years ago
White Belt
0

Did you ever find a solution to this?

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ