| Junior Member with 1 posts. | | | |
Assuming you want to script clearing the recycle bin as part of an automated cleanup, then easiest way to do it thoroughly is to use the CleanMgr utility from the command line.
Create a text file titled “DiskCleanmgr.reg” in the same directory as your batch file and copy and paste the below 4 lines into it. Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Volum eCaches\Recycle Bin] "StateFlags0001"=dword:00000002
Then in your batch file add the below two lines regedit /s DiskCleanmgr.reg cleanmgr /sagerun:1
The reason I have made the option /sagerun:1 is because the StateFlags0001 in the regedit file is set to 1. If you didn’t do the registry hack then you would have to manually pick the recycle bin after running the command cleanmgr /sageset:1, the registry file keeps setting the options silent. When run the utility graphically launches but runs and closes automatically. |