Free Disk Space in Windows 10 by Automating Disk Cleanup

Posted on February 12, 2016 by Daniel Petri in Windows 10 with 0 Comments

Windows 10 Hero Good

In a previous article, I explained how to use the Disk Cleanup utility to clean up temporary files on your Windows 10 machine. If you’re an administrator of a network that contains multiple computers, then running manual configuration tasks can be very time consuming. In this article, I’ll show you how to automate this process for larger environments.

Automating Disk Cleanup: One Approach

If you want to pre-configure these options on a remote computer and offer the user the ability to execute a script that will clean their disk, then you can use the following instructions to create .BAT file, place it on the computer’s desktop or anywhere you like, and execute it with elevated permissions:

Saving our .BAT file. (Image Credit: Daniel Petri)

Saving our .BAT file. (Image Credit: Daniel Petri)

Running the .BAT file to start the Disk Cleanup utility. (Image Credit: Daniel Petri)

Running the .BAT file to start the Disk Cleanup utility. (Image Credit: Daniel Petri)

If you would like to schedule Disk Cleanup to run automatically, then you can do so using the Task Scheduler. Assuming you’ve pre-configured the system with the required settings to be cleaned by using the cleanmgr /sageset:100 command, or running the registry settings that are provided in this article, then the system will already know that if it runs cleanmgr /sagerun:100, and all the required files will be cleaned.

Now we need to create the scheduled task to run the command.

To do so, follow these steps:

1. Open Task Scheduler from the Administrative Tools folder.

2. In the Task Scheduler window, click on “Create Basic Task.”

Creating a basic task in Task Scheduler. (Image Credit: Daniel Petri)

Creating a basic task in Task Scheduler. (Image Credit: Daniel Petri)

3. Give the task a name and description. Click “Next.”

Naming the basic task in Task Scheduler. (Image Credit: Daniel Petri)

Naming the basic task in Task Scheduler. (Image Credit: Daniel Petri)

4. Select the option that best suits your needs. For this article, we’ll be using the monthly option. Click “Next.”

Selecting the task trigger. (Image Credit: Daniel Petri)

Selecting the task trigger. (Image Credit: Daniel Petri)

Sponsored

5. Select when you’d like to run the task. I chose the first Sunday of each month. Click “Next.”

Selecting time and day for the command to execute. (Image Credit: Daniel Petri)

Selecting time and day for the command to execute. (Image Credit: Daniel Petri)

6. Now we need to give our task an action to execute. In this article, we’ll select “Start a program.” Click “Next.”

Selecting an action for our task. (Image Credit: Daniel Petri)

Selecting an action for our task. (Image Credit: Daniel Petri)

7. Use the following path:

Add argument as

Click “Next.”

automating-disk-cleanup-22

8. To complete the creation of our task, click “Finish.”

automating-disk-cleanup-23

Sponsored

Now, either wait for the time of the task to arrive, or, if you want to check if it works right now, find it in the scheduled tasks library, right-click it, and select “Run.” If it runs, you’ll see it, and you can also check the last run status.

Running the task. (Image Credit: Daniel Petri)

Running the task. (Image Credit: Daniel Petri)

The task successfully executed. (Image Credit: Daniel Petri)

The task successfully executed. (Image Credit: Daniel Petri)

 

 

Sponsored