Trying to delete .exe files of a set size, recursively – but VBscript is not my forte, Can anyone see an obvious reason for it not working recursively?
OPTION EXPLICIT
DIM strFolder
DIM objFSO
strFolder = "C:\TESTFOLDER"
set objFSO = createobject("Scripting.FileSystemObject")
RecursiveDelete strFolder
wscript.echo "Finished"
sub RecursiveDelete(byval strDirectory)
DIM objFolder, objSubFolder, objFile
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
if ( RIGHT(UCASE(objFile.Path),4) = ".EXE" ) AND (file.Size == 47232 ) then
wscript.echo "Deleting:" & objFile.Path
objFile.Delete
end if
next
for each objSubFolder in objFolder.SubFolders
RecursiveDelete objSubFolder.Path
next
end sub
This:
should be: