Date created: Sunday, June 19, 2011 10:17:04 AM. Last modified: Thursday, December 13, 2012 11:41:20 AM
Empty Recycling Bin
This is a script I wrote to run at logoff because I am crazy about having an empty recycling ben when using Windows;
'************************************************
' Script to delelete items in the recycling bin,
' originally written and published by Courtney Jimenez on 05/02/05
' Mashed up by James Bensley on 16/04/2010
'
'************************************************
Option Explicit 'Play safe kids, don't get caught out.
'Declare all variables, FileSystejm Object, Shell Application Object, Recycling Bin Object,
Dim g_objFSO, objShellApp, objRecycleBin, objFolderItems, objItem
'Setup main variables and objects
Set g_objFSO = CreateObject("Scripting.FileSystemObject") 'Create a File System Object for deleting items
Set objShellApp = CreateObject("Shell.Application") 'Create a Shell Application for getting special folders
Set objRecycleBin = objShellApp.NameSpace(10) ' Grab special folder No.10, the recycling bin (not always 10)
Set objFolderItems = objRecycleBin.Items() 'Get items within Recycle Bin
'Loop round each item in the recycling bin and delete it with our FileSystem object
For Each objItem In objFolderItems
If (objItem.Type = "File Folder") Then 'Check for file type
g_objFSO.DeleteFolder(objItem.Path) 'Delete Folders
Else
g_objFSO.DeleteFile(objItem.Path) 'Delete Files
End If
WScript.Echo "Deleted " & objItem.Name
Next
Previous page: Disk Usage
Next page: File Distribution per Department