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

Comments

Please log in to comment

Answers

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?
Answered 12/05/2016 by: rileyz
Red Belt

  • Windows Temp is getting deleted without issue, the issue is only with SageRun
Please log in to comment
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.
Answered 12/06/2016 by: andys0123
Orange Senior Belt

  • 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
Please log in to comment
Answer this question or Comment on this question for clarity