Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
Dim fso, startFolder, OlderThanDate
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = "c:\Documents and Settings\" ' folder to start deleting (subfolders will also be cleaned)
OlderThanDate = DateAdd("d", -2, Date) ' 30 days (adjust as necessary)
DeleteOldFiles startFolder, OlderThanDate
Function DeleteOldFiles(folderName, BeforeDate)
Dim filename, folder, file, fileCollection, folderCollection, subFolder
Set folder = fso.GetFolder(folderName)
Set folderCollection = folder.SubFolders
For Each subFolder In folderCollection
filename = subFolder.Path & "\Application Data\Mozilla\Firefox\Profiles\3w7is70x.default\Pluginreg.dat"
if fso.FileExists(filename) then
set file = fso.GetFile(filename)
If file.DateLastModified < BeforeDate Then
fso.Deletefile(filename)
end if
end if
filename = subFolder.Path & "\Application Data\Mozilla\Firefox\Profiles\3w7is70x.default\Blocklist.xml"
if fso.FileExists(filename) then
set file = fso.GetFile(filename)
If file.DateLastModified < BeforeDate Then
fso.Deletefile(filename)
end if
end if
Next
End Function
Dim fso, startFolder, OlderThanDate
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = "D:\Documents and Settings\" ' folder to start deleting (subfolders will also be cleaned)
OlderThanDate = DateAdd("d", -2, Date) ' 30 days (adjust as necessary)
DeleteOldFiles startFolder, OlderThanDate
Function DeleteOldFiles(folderName, BeforeDate)
Dim folder, file, fileCollection, folderCollection, subFolder
Set folder = fso.GetFolder(folderName)
Set fileCollection = folder.Files
For Each file In fileCollection
if file.Name = "Blocklist.xml" or file.Name = "Pluginreg.dat" Then
If file.DateLastModified < BeforeDate Then
fso.DeleteFile(file.Path)
End If
end if
Next
Set folderCollection = folder.SubFolders
For Each subFolder In folderCollection
DeleteOldFiles subFolder.Path, BeforeDate
Next
End Function
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = "D:\Documents and Settings\"
For Each subFolder in fso.getFolder(startFolder).SubFolders
If fso.FolderExists(subFolder.path & "\Application Data\Mozilla") Then
For Each profileFolder in fso.GetFolder(subFolder.path & "\Application Data\Mozilla\FireFox\Profiles\").SubFolders
If fso.FileExists( profileFolder & "\BlockList.xml") Then
fso.DeleteFile (profileFolder & "\BlockList.xml")
End If
If fso.FileExists( profileFolder & "\pluginreg.dat") Then
fso.DeleteFile (profileFolder & "\pluginreg.dat")
End If
Next
End If
Next
strStartFolder = "C:\Documents and Settings"
arrFilesToDelete = Array("Pluginreg.dat", "Blocklist.xml")
Set wshShell = CreateObject("WScript.Shell")
For Each strFileToDelete In arrFilesToDelete
wshShell.Run "Cmd.exe /c del /S /Q """ & strStartFolder & "\" & strFileToDelete & """", 1, True
Next
MsgBox "Done!"
Dim fso, OlderThanDate, profile_path
Set fso = CreateObject("Scripting.FileSystemObject")
profile_path = "d:\Documents and Settings\USER_PROFILE\Application Data\Mozilla\FireFox\Profiles\"
OlderThanDate = DateAdd("d", -2, Date) ' 30 days (adjust as necessary)
Dim folder,folders,profile
Set folder = fso.GetFolder("d:\Documents and Settings\" )
Set folders = folder.SubFolders
for each profile in folders
DeleteOldFiles Replace(profile_path, "USER_PROFILE", profile.Name), OlderThanDate
next
Function DeleteOldFiles(folderName, BeforeDate)
Dim folder, file, fileCollection, folderCollection, subFolder
if(fso.FolderExists(folderName)) then
Set folder = fso.GetFolder(folderName)
Set fileCollection = folder.Files
For Each file In fileCollection
if file.Name = "Blocklist.xml" or file.Name = "Pluginreg.dat" and (file.DateLastModified < BeforeDate) Then
fso.DeleteFile(file.Path)
End If
Next
Set folderCollection = folder.SubFolders
For Each subFolder In folderCollection
DeleteOldFiles subFolder.Path, BeforeDate
Next
end if
End Function
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.