VB Script - Empty Recycle Bin
Posted on 2014-01-02
I have a VB Script that cleans up various things on the C drives of servers. The only part I am having trouble with is cleaning the recycle bin. Here is the sub that I have that isn't working:
SUB Recycle (strComputer, StrDrive)
strDrive1 = Left(strDrive, 1)
Set FSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "\\" & strComputer & "\" & strDrive1 & "$\RECYCLER"
If Not FSO.FolderExists(sDirectoryPath) Then
sDirectoryPath = "\\" & strComputer & "\" & strDrive1 & "$\$Recycle.Bin"
Set objFolder = FSO.GetFolder(sDirectorypath)
CALL DeleteFiles (objFolder)
For Each objFile in objFolder.Files
For Each objSubFolder In objFolder.Subfolders
Maybe having two subs is creating the issue? Any help is appreciated.