Option Explicit Dim blnCScript, blnNoConfirm, blnQuiet, intDel Dim objFolder, objFSO, objSubFolder, wshShell Dim strFlashSettings, strFolder, strMsg ' Create file system object Set objFSO = CreateObject( "Scripting.FileSystemObject" ) ' Display a help message, unless the /Q switch ' (Quiet mode) was used on the command line strMsg = objFSO.GetFileName( WScript.ScriptFullName ) _ & ", Version 1.00" & vbCrLf _ & "Delete all ""Local Shared Objects"", " _ & "also known as ""Flash Cookies"", from the" & vbCrLf _ & "current user's profile" & vbCrLf & vbCrLf _ & "Usage: " _ & objFSO.GetBaseName( WScript.ScriptFullName ) _ & " [ /Q | /S ]" & vbCrLf & vbCrLf _ & "Where: /Q Quiet mode (NO prompts for confirmation, " _ & "NO results on screen)" & vbCrLf _ & " /S Summarize (NO prompts for confirmation, " _ & "BUT results on screen)" & vbCrLf _ & " (Default: BOTH prompts for confirmation " _ & "AND results on screen)" & vbCrLf & vbCrLf _ & "Notes: It is recommended to run this script " _ & "without any command line switches" & vbCrLf _ & " the first time (with the user ID for which it is " _ & "intended) to confirm" & vbCrLf _ & " that the folders to be deleted " _ & "are the right ones." & vbCrLf _ & " Though every effort has been made to " _ & "avoid failures, no guarantee can" & vbCrLf _ & " be made for the proper functioning " _ & "of this script on your computer." & vbCrLf _ & " Use this script entirely at your own risk!" & vbCrLf _ & " To manage Flash Cooky settings, visit" _ & " http://www.macromedia.com/support" & vbCrLf _ & " /documentation/en/flashplayer/help" _ & "/settings_manager02.html" & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" If WScript.Arguments.Unnamed.Count > 0 Then WScript.Echo strMsg Set objFSO = Nothing WScript.Quit 1 End If With WScript.Arguments.Named If .Count > 1 Then WScript.Echo strMsg Set objFSO = Nothing WScript.Quit 1 End If If .Count = 1 And Not .Exists("Q") And Not .Exists("s") Then WScript.Echo strMsg Set objFSO = Nothing WScript.Quit 1 End If If .Exists("Q") Then blnQuiet = True Else blnQuiet = False End If If .Exists("S") Then blnNoConfirm = True Else blnNoConfirm = False End If End With ' Determine the scripting engine If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then blnCScript = True strMsg = strMsg & vbCrLf & vbCrLf & vbCrLf Else blnCScript = False End If ' Display the help unless in Quiet Mode If Not blnQuiet Then WScript.Echo strMsg ' Create scripting shell object Set wshShell = CreateObject( "WScript.Shell" ) ' Locate the Macromedia Flash settings folder in the current user's profile strFlashSettings = wshShell.ExpandEnvironmentStrings( "%UserProfile%" ) _ & "\Application Data\Macromedia\Flash Player" ' Delete all files and folders in the subfolder ' "#SharedObjects", but keep the subfolder itself strFolder = strFlashSettings & "\#SharedObjects" intDel = DelTree( strFolder, False, blnNoConfirm ) ' Delete only subfolders, not files, of the subfolder ' "macromedia.com\support\flashplayer\sys" strFolder = strFlashSettings & "\macromedia.com\support\flashplayer\sys" Set objFolder = objFSO.GetFolder( strFolder ) For Each objSubFolder In objFolder.SubFolders intDel = intDel + DelTree( objSubFolder.Path, True, blnNoConfirm ) Next ' Format message strMsg = "Results of " _ & objFSO.GetFileName( WScript.ScriptFullName ) _ & " run at " & Date & ", " & Time & ":" & vbCrLf If intDel = 1 Then strMsg = strMsg & "1 object deleted" Else strMsg = strMsg & intDel & " objects deleted" End If ' Display message, unless /Q (Quiet mode) was specified on the command line If Not blnQuiet Then WScript.Echo strMsg ' Release objects Set objFSO = Nothing Set wshShell = Nothing Function ConfirmDelete( myFolder, blnIncludeRoot, blnSilent ) ' Abort if in Quiet Mode If blnQuiet Or blnSilent Then ConfirmDelete = True Exit Function End If Dim intButtons, strPrompt, strTitle ' Format the prompt text to be displayed If blnIncludeRoot Then strPrompt = "Delete folder """ _ & Replace( myFolder, """", "" ) _ & """ and all of its contents?" Else strPrompt = "Delete the contents of folder """ _ & Replace( myFolder, """", "" ) & """?" End If ' Use StdIn and StdOut if we're running ' in CSCRIPT, or use MsgBox otherwise If blnCScript Then WScript.StdOut.Write strPrompt & "(Y/N): " If UCase( WScript.StdIn.ReadLine( ) ) = "Y" Then ConfirmDelete = True Else ConfirmDelete = False End If WScript.StdOut.WriteBlankLines(1) Else intButtons = vbYesNo + vbDefaultButton2 + vbQuestion strTitle = "Please confirm folder deletion" If MsgBox( strPrompt, intButtons, strTitle ) = vbYes Then ConfirmDelete = True Else ConfirmDelete = False End If End If End Function Function DelTree( myFolder, blnIncludeRoot, blnSilent ) Dim intCount, objMyFile, objMyFolder, objMySubFolder Const FORCE_DEL = True ' Reset counter of deleted files and folders intCount = 0 If objFSO.FolderExists( myFolder ) Then ' Ask for confirmation unless in Quiet Mode If ConfirmDelete( myFolder, blnIncludeRoot, blnSilent ) Then ' Create folder object Set objMyFolder = objFSO.GetFolder( myFolder ) ' First delete all files in the folder For Each objMyFile In objMyFolder.Files objMyFile.Delete FORCE_DEL intCount = intCount + 1 Next ' Next recurse through subfolders For Each objMySubFolder In objMyFolder.SubFolders intCount = intCount + DelTree( objMySubFolder.Path, True, True ) Next ' Finally remove the folder itself, unless second ' argument to function (blnIncludeRoot) was False If blnIncludeRoot = True Then objMyFolder.Delete FORCE_DEL intCount = intCount + 1 End If ' Release folder object Set objMyFolder = Nothing Else WScript.Echo "Skipped folder """ _ & Replace( myFolder, """", "" ) & """" End If Else WScript.Echo "Error: Folder """ _ & Replace( myFolder, """", "" ) _ & """ not found!" End If ' Return number of deleted files and folders DelTree = intCount End Function