Site icon ECTT Media News

7 Easy Steps to Automatically Delete Temporary Files in Windows 11

7 Easy Steps to Automatically Delete Temporary Files in Windows 11

Windows 11, like previous versions of Windows, accumulates temporary files over time.

These files are created for various reasons, such as during software installations, updates, or everyday operations.

If not cleared regularly, they can eat up disk space and reduce system performance.

Rather than deleting these files manually, you can automate the process to save time and maintain your PC’s efficiency.

Here’s how to set it up.

Step 1: Create a Batch Script to Clear Temporary Files

To begin automating the cleanup process, you’ll need to write a script.

This batch file will remove files from both the user and system-wide temporary directories.

Follow these steps to create the script:

@echo off
echo Cleaning system and user temp files...
del /s /f /q %TEMP%\*.* >nul 2>&1
rd /s /q %TEMP% >nul 2>&1
md %TEMP%
del /s /f /q C:\Windows\Temp\*.* >nul 2>&1
rd /s /q C:\Windows\Temp >nul 2>&1
md C:\Windows\Temp
echo Temporary files cleared!

You’ve now created an automated cleanup script.

Step 2: Schedule the Script Using Task Scheduler

To ensure your script runs at a regular interval, use the Task Scheduler.

Here’s how to configure it:

Your task is now active and will run automatically based on your chosen schedule.

Step 3: Add More Cleanup Options to the Script

To make your script even more effective, you can include commands to remove other junk files.

Here’s how to expand its functionality:

PowerShell.exe -Command "Clear-RecycleBin -Force"
net stop wuauserv
rd /s /q C:\Windows\SoftwareDistribution\Download
net start wuauserv
del /s /f /q C:\Windows\Prefetch\*.* >nul 2>&1

Adding these lines will ensure your PC stays clean across multiple storage locations.

Step 4: Run Script at Startup or Shutdown

You can configure Windows to run your script automatically when the system starts or shuts down.

Here’s how to do both:

Run at Startup

Run at Shutdown (Windows 11 Pro Only)

Note: This option is only available on Windows 11 Pro and not on the Home edition.

Step 5: Use Storage Sense for Built-In Cleanup

If you prefer using built-in tools, Storage Sense in Windows 11 is another way to remove temporary files.

Here’s how to enable it:

Conclusion

By using a combination of custom scripts and built-in tools, you can automate the removal of temporary files in Windows 11.

This not only frees up valuable storage space but also keeps your system running smoothly.

Whether you choose to run the cleanup daily, at startup, or on shutdown, these methods offer flexibility and control.

So pick the one that suits your workflow and enjoy a faster, cleaner PC.

Exit mobile version