System hacks: automatic cleaning C disk thinning has a trick

We all know that after using Windows 10 system for a long time, the C drive space will be tight, resulting in various inexplicable system failures. However, it is troublesome to clean up the C drive manually every time, and cleaning up the C drive can actually be automated.

Automatic cleaning of temporary files

Even normal operations will bring a lot of temporary files, such as cache files from downloaded software, cache files from online playback, temporary files from installed programs, etc. Most temporary files can be deleted. Most of the temporary files can be deleted, and for Windows 10 users (who need to update to Creators 1703 or later), the system can delete too many temporary files through the “Storage Aware” component that comes with it.

Type “Storage” in the search box and set “Storage Awareness” to “On” in the Storage Settings pane that opens. This will allow it to automatically sense when space is tight on the C drive and clean it up automatically (Figure 1).

201816zzql1

Figure 1 Turn on Auto Sense

Of course, we can customize the settings for auto-awareness by clicking “Change detailed settings” to enter the settings page, where you can set the settings according to your actual needs. For example, for SSD hard drive users with small C drive space, you can set the run storage awareness period to weekly and set the temporary files to 14 days, so that the above operation will be performed automatically in the specified period (Figure 2).

201816zzql2

Figure 2 Customized Perception

Run disk cleanup on a regular basis

In addition to temporary files, Windows 10 also generates various unwanted files after running for a period of time, such as system upgrade patches, residual files from old system upgrades and so on. These files take up a lot of space on the C drive, and they can be deleted automatically and safely with the help of the Disk Cleanup component.

However, if you run the “Disk Cleanup” component directly by default, not only will you delete fewer junk files, but you will also need to click on all of them each time to complete the deletion, and if you are deleting files like system updates and old system upgrades, you will need to manually click on “Clean up system files” each time to complete the cleanup. If you want to delete files like system updates and old system upgrades, you need to manually click “Clean up system files” every time to scan the system again to complete the cleanup, but now you can do it automatically with the command line.

Start Notepad and type the following command and save it as a “clean.bat” batch for your desktop.

cleanmgr /sageset:99

cleanmgr /sagerun:99 /autoclean

Code explanation.

/sageset:99, means that sageset displays the disk cleanup settings dialog and creates a registry entry to store the settings selected by the user. 99 means that the number of disk cleanup disk cleanup profiles is specified (usually a setting of 99 is sufficient). This profile value will be stored in the registry so that it can be called directly the next time the command is used.

/sagerun:99 runs the configuration file set up above, so that the system will automatically clean up the relevant items according to the previous settings after running. /autoclean means that the cleanup is done automatically.

In this way, if you want to clean up the junk files on the C drive in the future, right-click “clean.bat” on the desktop and select “Run as administrator”, after starting the batch process, the disk cleanup settings window will pop up, and you can see that after adding the /sageset:99 parameter, the cleanup items will be displayed more than when you run the “Cleanup” component directly (Figure 3). After adding the /sageset:99 parameter, the cleanup items will be displayed more than running the “Disk Cleanup” component directly, and there is no “Cleanup System Files” button (Figure 3).

201816zzql3

Figure 3 Displaying the Disk Cleanup Settings window

Check all the items that need to be cleaned as prompted and click “OK”, so that these selected items will be automatically saved to the registry and configuration files, and then you will continue to run the “cleanmgr /sagerun:99 /autoclean ” command (Figure 4).

201816zzql4

Figure 4 Run command

After the above command is run, it will automatically start the scan and delete files of Disk Cleanup, you can see that the Scan and Cleanup Files windows will pop up on the screen in turn, and after these operations are completed, all disk junk files will be automatically finished (Figure 5).

201816zzql5

Figure 5 Automatic cleaning

Similarly, many junk files on the system can be removed with the help of the command line, for example, by typing “del /f /s /q %systemdrive%*.tmp” to delete all temporary files and “el /f /s /q “% userprofile%Local SettingsTemporary Internet Files*. *”” can delete all IE temporary cache files, etc. Because all these operations are done through the command line, we can also combine with the system task schedule for regular deletion.

Further slimming, custom management of oversized files

In addition to the above-mentioned junk files that can be deleted, the C drive by default will also save some large system files, which are generally not recommended for deletion, but we can manage them by migration or compression to further reduce the space occupied by the C drive.

C drive virtual memory file, you can go to “System Settings → Advanced Properties → Performance Options → Advanced”, and then remove “Automatically manage paging file size for all drives”, customize the size of the C drive paging file (the default size and memory consistent), or set the paging file to a partition other than C drive (Figure 6). For example, users with large memory can set it smaller), or set the paging file to a partition other than the C drive (Figure 6).

201816zzql6

Figure 6 Customizing the paging file

If you like to use the hibernate function but feel that it takes up too much space, you can start a command prompt as administrator and type “powercfg hibernate size 40”, where 40 means the hibernate file size is kept at 40% of the system memory when hibernating (Figure 7). The hibernate file size is kept at 40% of the system memory size (Figure 7).

201816zzql7

Figure 7 Compressing dormant files

This way, when the system enters hibernation, the hibernation files will take up less space, as you can see from the comparison before and after compression, using 40% compression can greatly reduce the space occupied by the C drive (Figure 8). However, please note that the ratio should not be set too small, otherwise the Hiberfil.SYS will fail to hibernate due to lack of space. 60 is recommended for 4G RAM, 40-50 for 8G and above.

201816zzql8

Figure 8 Comparison before and after compression

Leave a Comment