[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Batch process to delete folers and bypass recycle bin on WinNT

Posted on 2005-04-23
8
Medium Priority
?
1,466 Views
Last Modified: 2008-01-09
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
      Next
     
     Set Folder = Nothing
     Set Folders = Nothing
   
  End Function


Thanks, TT
0
Comment
Question by:TommyTupa
7 Comments
 
LVL 2

Expert Comment

by:SOFTECNICOS
ID: 13851089
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.
0
 
LVL 13

Author Comment

by:TommyTupa
ID: 13851142
I need to delete folders older than x number of days.  Didn't think this can be done with CMD.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:FlyBoy97
ID: 13851750
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.

FlyBoy97
0
 
LVL 12

Accepted Solution

by:
kneH earned 2000 total points
ID: 13858915
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.
0
 
LVL 4

Expert Comment

by:LittleRed1
ID: 13863510
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%.
0
 
LVL 13

Author Comment

by:TommyTupa
ID: 13868331
I really appreciate everyone's input.  I'll do some testing later this week and follow up.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question