Monday, August 11, 2014

Deleting Folders & Subfolders using VBscript


Set folder = fso.GetFolder("C:\Program Files\Test")
' delete all files in root folder
for each f in folder.Files
   On Error Resume Next
   name = f.name
   f.Delete True
   
   On Error GoTo 0
Next

' delete all subfolders and files
For Each f In folder.SubFolders
   On Error Resume Next
   name = f.name
   f.Delete True
   
   On Error GoTo 0
Next

No comments:

Post a Comment