Batch process to delete folers and bypass recycle bin on WinNT

I have a batch file to delete folders on a WindowsNT Server shown at the end of this question.  My problem is that the folders I'm deleting are 26GB. Is there any way to bypass the recycle bin while deleting?  

Here's the function I'm using right now:
Private Function fDeleteFolders(BackupPath,TSO)
    Dim FSO
    Dim Folders
    Dim Folder
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Folders = FSO.GetFolder(BackupPath)
      For Each Folder In Folders.subFolders
         If DateDiff("d", Folder.DateCreated, Date) < 10 Then
              TSO.Write "Deleted: " & Folder.Name & vbCrLf
              Folder.Delete True
              fDeleteFolders = "true"
        End If
     Set Folder = Nothing
     Set Folders = Nothing
  End Function

Thanks, TT
LVL 13
Who is Participating?
Why not delete the recycle bin?!

It gets places back when you reboot.

Anyways to have the bin not deleted change the attributes :)

attrib c:\recycler +r /s
then run your delete program
then change the attributes back
attrib c:\recycler -r /s /a

Might be c:\recycled ... not sure. Also test the /a switch.

Just create a batchfile to first change the attribs, then run your program and then change the attribs back.
Why don't you use a simple CMD file with the delete command, so in that way you don't put the files in recicle bin.
TommyTupaAuthor Commented:
I need to delete folders older than x number of days.  Didn't think this can be done with CMD.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Instead of rewriting your already fine batch file change the way your recycle bin works. Use gpedit.msc go to User Configuration, Administrative Template, Windows Explorer, open Maximum Allowed Recycle Bin Size. Enable the policy and input a number between 0 and 100% to represent the amount of disk your recycle bin is allowed to take up, all other files will be permanently deleted.

This can be done with a CMD file, but it gets a little complex in determining what the date was 90 day ago. There are also difficulties in dealing with different date and time formats that are used at the system level.
I would recommend you find a better way of dealing with the recycle bin or use the VBS to enumerate the files that need to be deleted and then call the shell to do DEL /Q /F %path%\%filename%.
TommyTupaAuthor Commented:
I really appreciate everyone's input.  I'll do some testing later this week and follow up.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.