Running Windows 10 Disk Cleanup


Running Disk clean up can free up space by cleaning out a variety of files left over from windows updates, operating system upgrades, and installation of applications.


Step1 is to select the types of files you want removed; this process creates the registry settings that will be exported and applied to the target systems you wish to clean.


On a Windows 10 system open the command prompt and navigate to c:\windows\system32

Run the following command.




Cleanmgr.exe /sageset:1   

(The number represents the config setting, so edit the number if you wish to make a different configuration settings)

This will open a dialog box, check off the types of files you wish to remove when using that configuration.


Step 2 Once you have saved the settings the next step is to export those Registry settings.

Open up Regedit.

Navigate to 



Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches

Select File, Export and give the file a name.

In our example we called out file sage1.reg



Create a folder called diskclean under your shared apps folder.


Copy the registry file sage1.reg to this folder.


Copy regedit.exe from a windows 10 machine to the diskclean folder, the file can be found in the windows folder.




Step 3 Create a batch file that will install the registry settings on the target systems.

@ECHO OFF

c:

cd\

mkdir c:\tmps

xcopy /Y \\<servername>\apps\diskclean\*.* c:\tmps 

cd \tmps

regedit /s sage1.reg

cd\

rd c:\tmps /S /Q

exit


Change to the name of your server



Step 4 Create a Third-Party Deployment Template to run the batch file.


*PLEASE NOTE – you must check off copy files locally.






Step 5 Create a Batch file that will run the cleanmgr configuration.

cleanmgr.exe /sagerun:1

in our example we will name the file cleanmgr-sage1.bat


Step 6 Download the utility to wrap the bat file into an exe.

Download the free utility from https://f2ko.de/

Install the utility.


Step 7 Wrap the bat file into an exe.



Open the utility and browse to select the bat file created for running the cleanmgr.

Select Invisible Application, and Add Administrator Manifest

Enter a file name in the Save As and click on Compile.


Step 8 Create a Third-Party Template to run the Bat File Executable

**PLEASE NOTE – you must select an Authentication template that uses a non-UAC setting.


Also check off Do Not Check for Process as the time taken to run the cleanmgr may take more than 10 minutes.

In our example we called our template Disk Clean Sage 1 App





Step 9 Running the Job



Select the Target systems, right click to select Deploy Third Party Software, select the template name that deploys the registry settings for the cleanmgr, then click add task. Select Deploy Third Party Software, select the template name that deploys the bat file executable, remember to change the authentication for this task to use the Non-UAC Authentication template.



You can configure a schedule for when the job will run or Click to run the job immediately without a schedule.


 




Authentication Templates


The following are the settings for the UAC Enabled Authentication Template


The following are the settings for the Non-UAC Authentication Template




**PLEASE NOTE – The SyAM Management utility service needs to run as the username and password used in the authentication templates.