Option Explicit Dim intItems, intSize, objBin, strMsg ' Get BinManager object Set objBin = CreateObject( "BinManager.RecycleBin" ) intItems = objBin.NumItems intSize = objBin.Size Select Case WScript.Arguments.Named.Count Case 0 ' This is ok, it means empty the Recycle Bin Case 1 ' /Q would be the only valid argument If Not WScript.Arguments.Named.Exists( "Q" ) Then Syntax Case Else Syntax End Select Select Case WScript.Arguments.Unnamed.Count Case 0 objBin.Empty If Not WScript.Arguments.Named.Exists( "Q" ) Then Report Case 1 If IsNumeric( WScript.Arguments.Unnamed(0) ) Then objBin.DeleteOldItems CInt( WScript.Arguments.Unnamed(0) ) If Not WScript.Arguments.Named.Exists( "Q" ) Then Report Else Syntax End If Case Else Syntax End Select ' Report the contents of the recycle bin. Sub Report( ) strMsg = CStr( intItems - objBin.NumItems ) _ & " items were removed from the Recycle Bin (" _ & FormatNumber( ( intSize - objBin.Size ) / 1048576, 1, True, False, False ) _ & " MB)" & vbCrLf intSize = FormatNumber( objBin.Size / 1048576, 1, True, False, False ) WScript.Echo strMsg & "The Recycle Bin still holds " & objBin.NumItems _ & " items (" & intSize & " MB)" End Sub Sub Syntax strMsg = vbCrLf _ & "DelTrash2.vbs, Version 1.00" & vbCrLf _ & "Empty the Recycle Bin, or remove only files" & vbCrLf _ & "older than the specified number of days" & vbCrLf & vbCrLf _ & "Usage: DELTRASH2.VBS [ days ] [ /Q ]" & vbCrLf & vbCrLf _ & "Where: days is the minimum age in full calendar days of files to be deleted" & vbCrLf _ & " (0 means delete everything older than today)" & vbCrLf _ & " /Q suppresses screen output (number of items and MBs)" & vbCrLf & vbCrLf _ & "Notes: [1] This script requires BinManager by Tim Tabor" & vbCrLf _ & " http://www.cheztabor.com/BinManager/" & vbCrLf _ & " [2] This script was based on Tim Tabor's own JScript sample" & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" & vbCrLf WScript.Echo strMsg Report WScript.Quit 1 End Sub