There's no such thing as a stupid question, but they're the easiest to answer.


Windows XP Windows XP
Search Search
Search for:
Tech Support Guy > > >

How do empty recycle bin from command line


ajpow365's Avatar
ajpow365 ajpow365 is offline
Computer Specs
Junior Member with 2 posts.
Join Date: Oct 2007
Location: Baxter, MN
Experience: Advanced
17-Oct-2007, 10:15 AM #1
How do empty recycle bin from command line
I am creating a .bat file to do a task and after it is complete, I delete some files.

How do I clear the recycle bin?

Can't seem to get a good answer.

WhitPhil's Avatar
Computer Specs
Trusted Advisor - Gone but never forgotten with 8,684 posts.
Join Date: Oct 2000
Location: Whitby, Ontario
17-Oct-2007, 01:12 PM #2
The files shouldn't be in the recycle bin. They will be "permanently" deleted.
VegasRage's Avatar
VegasRage VegasRage is offline
Junior Member with 1 posts.
Join Date: Jun 2008
26-Jun-2008, 02:16 PM #3
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]

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.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

You Are Using: Server ID
Trusted Website Back to the Top ↑