How to empty recycling bin from command line in Windows XP?
5 Answers
As I posted elsewhere, I use rmdir /q /s C:\Recycler
to empty the Recycle Bin. If you have multiple drives, then replace C: with that drive letter.
First, you need to create file called something like EmptyBin.reg like so:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin]
"StateFlags0001"=dword:00000002
Now, you create a batch (*.bat) file with the following:
regedit /s EmptyBin.reg
cleanmgr /sagerun:1
Run that batch file from the command line to empty your bin.
-
Unfortunately it doesn't work for me. It clears some system caches, but it leaves recycling bin untouched :/ Feb 7, 2010 at 9:25
-
while
rd /s /q %systemdrive%\$RECYCLE.BIN
will delete the $RECYCLE.BIN folder from the system drive, which is usually c:, one should consider deleting it from any other available partitions since there's an hidden $RECYCLE.BIN folder in any partition in local and external drives (but not in removable drives, like USB flash drive, which don't have a $RECYCLE.BIN folder). For example, I installed a program in d:, in order to delete the files it moved to the Recycle Bin I should run:
rd /s /q d:\$RECYCLE.BIN
More information available at Stack Overflow at how to empty recyclebin through command prompt?
The recycle bin is just another folder; you should be able to delete the files from C:\RECYCLER to achieve the same effect as emptying the recycle bin from the GUI.
-
3The recycle bin is not a simple folder at all, but rather a virtual one. It's true that its contents are stored in the "Recycler" or "$Recycle.bin" directories on each drive root, but I wouldn't blindly delete their contents. It's probably OK, but it would feel like a dirty hack. :o)– efotinisFeb 6, 2010 at 13:57
I can use VBScript for this:
Dim objShell,objFolder,objItem,fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(10)
For Each objItem In objFolder.Items
fso.DeleteFile objItem
Next