(view source code of delflash.vbs as plain text)
Option ExplicitDim blnCScript, blnNoConfirm, blnQuiet, intDelDim objFolder, objFSO, objSubFolder, wshShellDim strFlashSettings, strFolder, strMsg' Create file system objectSet objFSO = CreateObject( "Scripting.FileSystemObject" )
' Display a help message, unless the /Q switch' (Quiet mode) was used on the command linestrMsg = 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
ElseblnQuiet = False
End If
If .Exists("S") Then
blnNoConfirm = True
ElseblnNoConfirm = False
End If
End With
' Determine the scripting engineIf UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
blnCScript = True
strMsg = strMsg & vbCrLf & vbCrLf & vbCrLf
ElseblnCScript = False
End If
' Display the help unless in Quiet ModeIf Not blnQuiet Then WScript.Echo strMsg
' Create scripting shell objectSet wshShell = CreateObject( "WScript.Shell" )
' Locate the Macromedia Flash settings folder in the current user's profilestrFlashSettings = wshShell.ExpandEnvironmentStrings( "%UserProfile%" ) _
& "\Application Data\Macromedia\Flash Player"
' Delete all files and folders in the subfolder' "#SharedObjects", but keep the subfolder itselfstrFolder = 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 messagestrMsg = "Results of " _
& objFSO.GetFileName( WScript.ScriptFullName ) _
& " run at " & Date & ", " & Time & ":" & vbCrLf
If intDel = 1 Then
strMsg = strMsg & "1 object deleted"
ElsestrMsg = strMsg & intDel & " objects deleted"
End If
' Display message, unless /Q (Quiet mode) was specified on the command lineIf Not blnQuiet Then WScript.Echo strMsg
' Release objectsSet objFSO = Nothing
Set wshShell = Nothing
Function ConfirmDelete( myFolder, blnIncludeRoot, blnSilent )
' Abort if in Quiet ModeIf blnQuiet Or blnSilent Then
ConfirmDelete = True
Exit Function
End If
Dim intButtons, strPrompt, strTitle ' Format the prompt text to be displayedIf blnIncludeRoot Then
strPrompt = "Delete folder """ _
& Replace( myFolder, """", "" ) _
& """ and all of its contents?"
ElsestrPrompt = "Delete the contents of folder """ _
& Replace( myFolder, """", "" ) & """?"
End If
' Use StdIn and StdOut if we're running ' in CSCRIPT, or use MsgBox otherwiseIf blnCScript Then
WScript.StdOut.Write strPrompt & "(Y/N): "
If UCase( WScript.StdIn.ReadLine( ) ) = "Y" Then
ConfirmDelete = True
ElseConfirmDelete = False
End If
WScript.StdOut.WriteBlankLines(1)
ElseintButtons = vbYesNo + vbDefaultButton2 + vbQuestion
strTitle = "Please confirm folder deletion"
If MsgBox( strPrompt, intButtons, strTitle ) = vbYes Then
ConfirmDelete = True
ElseConfirmDelete = False
End If
End If
End Function
Function DelTree( myFolder, blnIncludeRoot, blnSilent )
Dim intCount, objMyFile, objMyFolder, objMySubFolderConst FORCE_DEL = True
' Reset counter of deleted files and foldersintCount = 0
If objFSO.FolderExists( myFolder ) Then
' Ask for confirmation unless in Quiet ModeIf ConfirmDelete( myFolder, blnIncludeRoot, blnSilent ) Then
' Create folder objectSet objMyFolder = objFSO.GetFolder( myFolder )
' First delete all files in the folderFor Each objMyFile In objMyFolder.Files
objMyFile.Delete FORCE_DEL
intCount = intCount + 1
Next ' Next recurse through subfoldersFor 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 FalseIf blnIncludeRoot = True Then
objMyFolder.Delete FORCE_DEL
intCount = intCount + 1
End If
' Release folder objectSet objMyFolder = Nothing
ElseWScript.Echo "Skipped folder """ _
& Replace( myFolder, """", "" ) & """"
End If
ElseWScript.Echo "Error: Folder """ _
& Replace( myFolder, """", "" ) _
& """ not found!"
End If
' Return number of deleted files and folders DelTree = intCountEnd Function
page last modified: 2025-10-11; loaded in 0.0118 seconds