Description
Read the script header for details.
Source Code
'#==============================================================================
'#==============================================================================
'# SCRIPT.........: emptyRecycleBin.vbs
'# AUTHOR.........: Joe Glessner
'# EMAIL..........:
'# VERSION........: 1.0
'# DATE...........: 02OCT09
'# COPYRIGHT......: 2009, laoae.com
'# LICENSE........: Freeware
'# REQUIREMENTS...:
'#
'# DESCRIPTION....: Empties the Recycle Bin on the local computer.
'#
'# NOTES..........: This has only been tested on Windows 7, though it should
'# work on all Windows versions, 2000 or later.
'#
'# This script will empty the Recycle bin, but will not
'# change the icon to show it has been emptied, until the
'# recycle bin has been opened by a user.
'#
'# CUSTOMIZE......:
'#==============================================================================
'# REVISED BY.....:
'# EMAIL..........:
'# REVISION DATE..:
'# REVISION NOTES.:
'#
'#==============================================================================
'#==============================================================================
'**Start Encode**
'#==============================================================================
'# START OF SCRIPT
'#==============================================================================
'Option Explicit
'On Error Resume Next
'#--------------------------------------------------------------------------
'# Declare Constants
'#--------------------------------------------------------------------------
Const RECYCLE_BIN = &Ha&
Const FILE_SIZE = 3
'#--------------------------------------------------------------------------
'# Declare Variables
'#--------------------------------------------------------------------------
Dim objShell, objFolder, objFSO, colItems
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colItems = objFolder.Items
'#--------------------------------------------------------------------------
'# Delete everything in the Recycle Bin
'#--------------------------------------------------------------------------
For Each objItem in colItems
If (objItem.Type = "File folder") Then
objFSO.DeleteFolder(objItem.Path)
Else
objFSO.DeleteFile(objItem.Path)
End If
Next
'#==============================================================================
'# SUBROUTINES/FUNCTIONS/CLASSES
'#==============================================================================
'#==============================================================================
'# END OF FILE
'#==============================================================================
6 Spice ups
Thanks, It works very nice. FYI tested in Server 2003, XP and Vista and working good.
tatum9725
(Michael4687)
3
The Icon Stay the same as if it was full but it does delete the stuff in the recycle bin
tino
(Tino Todino)
4
Cool Thanks for doing a working one Joe. If I could delete mine I would…
Tino, Rather than delete it, find another script to put there, and rename it. Not the best solution, but it’ll get the job done.
How could I implement this script? I don’t know where to add the script in my system. Thanks
@kattieO It’s a VBScript, so you save it into a text file, then rename the file with a .vbs extension rather than .txt, and then double click it (if you have UAC turned on you may have to right click it and select Run As Administrator).
by the way, what if my files are in my file server. can i implement this script too?
This is a good idea. Especially for servers. I may have to try it. Thanks.
Worked like a charm. Thanks a lot mate.
jefftroop
(jeff8619)
12
“YOUR MY HERO” thanks for sharing 
iainsmart
(Iain Smart)
13
Works on Server 2008 if you change the file type to = “File Folder” NOTE: upper case on Folder
thanks for the script , here’s what i’m trying to do in my environment, most of the user keep files in the recycle bin which is consuming lots of space in server, so what i wanted is every time user log off his computer , all files in the bin should get delete, these are the location of recycle bin which i wanted to delete, Desktop, My Documents, Downloads, My Music, My Pictures, My Videos how to do this ??
This script works great for the most part, except that it would seem that if the items sitting in the recyle bin have their attributes set to read-only, they won’t get deleted. Has anyone else run into this issue or know of a solution for it?
There is another way to do it by creating the shortcut and passing the command "powershell.exe -command clear-recyclebin –Force"to it. whenever you run this shortcut recycle bin will clean up. For more info watch this video https://youtu.be/-pPiRJAx_Nk