Thursday, May 1, 2014

Deleting Appdata folder for all the users



Dim FSfolder 
Dim subfolder 
Dim i 


set objshell = CreateObject("Wscript.shell") 
Set FSO = CreateObject("Scripting.FileSystemObject")
Profile = strSysDrive & "C:\Users"
Set FSfolder = FSO.GetFolder(Profile) 'getting the user profile folders




'starting of the loop to delete the HKCUs


For Each subfolder In FSfolder.SubFolders


   If (subfolder.Name <> "All Users" And  subfolder.Name <> "Default User"_
   and subfolder.Name <> "Public" and subfolder.Name <> "Default") Then


 folder1=Profile & "\" & subfolder.Name & "\AppData\Roaming\Firefox"
 folder2=Profile & "\" & subfolder.Name & "\AppData\Local\Firefox"

DeleteThisFolder(folder1)
DeleteThisFolder(folder2)

  end if


Next 


Function DeleteThisFolder(FolderName)


    If FSO.FolderExists(FolderName) Then
      objshell.Run "CMD.EXE /C RD /S /Q """ & FolderName & """",0,True 
    End If


End Function

No comments:

Post a Comment