asked on
ASKER
strComputer = "."
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory where Name like '%Mozilla%'")
Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory where Name like '%Trash%'")
For Each objFolder In colFolders
' Verify the folder still exists if we are removing folders
' as the parent folder may have already been deleted.
If objFSO.FolderExists(objFolder.Name) Then
msgbox "Deleting " & objFolder.Name
' Uncomment the next line to actually delete the folder
' objFolder.Delete
End If
Next
msgbox "**** Done ****"
Dim objFSO, objFolder, objUserFolder, objRegEx
' Use RegEx for Pattern Matching
' Since RegEx is much faster if we just declare it once, use it here
' to make it more global
Set objRegEx = new RegExp
With objRegEx
.Global = True
.IgnoreCase = True
.pattern = "Mozilla"
End With
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Program Files (x86)") Then
Set objFolder = objFSO.GetFolder("C:\Program Files (x86)")
RemoveMozilla(objFolder)
End If
If objFSO.FolderExists("C:\ProgramData") Then
Set objFolder = objFSO.GetFolder("C:\ProgramData")
RemoveMozilla(objFolder)
End If
If objFSO.FolderExists("C:\Users") Then
For Each objFolder in objFSO.GetFolder("C:\Users").SubFolders
If objFSO.FolderExists(objFolder.Name & "\Appdata\Roaming") Then
Set objUserFolder = objFSO.GetFolder(objFolder.Name & "\Appdata\Roaming")
RemoveMozilla(objFolder)
End If
If objFSO.FolderExists(objFolder.Name & "\local") Then
Set objUserFolder = objFSO.GetFolder(objFolder.Name & "\Appdata\Roaming")
RemoveMozilla(objFolder)
End If
Next
End If
Sub RemoveMozilla (ParentFolder)
Dim objSubFolder
For each objSubFolder in ParentFolder.SubFolders
If objRegEx.Test(objSubFolder.Name) then
msgbox "Would Remove " & objsubfolder.Path
' Uncomment to actually Delete
' objSubFolder.Delete True
End If
Next
End Sub
ASKER
ASKER
VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.
TRUSTED BY
pls try
Open in new window
Regards