Posts

Showing posts from January, 2013

VBScript to Delete Folder and all SubFolders with files

Here is the VBScript which will delete all Folders and Subfolders with even have files in it. It took me so many hours to find this perfect script and all credits go to Rob van der Woude and the original script is here: http://www.robvanderwoude.com/vbstech_folders_deltree.php I just want to keep this for my reference and for everyone so that we all can save some time. Option Explicit Dim objFSO, objTempFolder, strTempFolder Const TEMP_FOLDER = 2 Set objFSO        = CreateObject( "Scripting.FileSystemObject" ) Set objTempFolder = objFSO.GetSpecialFolder( TEMP_FOLDER ) strTempFolder     = objTempFolder.Path DelTree strTempFolder, True Sub DelTree( myFolder, blnKeepRoot ) ' With this subroutine you can delete folders and their content, ' including subfolders. ' You can specify if you only want to empty the folder, and thus ' keep the folder itself, or to delete the folder itself as well. ' Root directories and some (not all)...