Jump to content
Sign in to follow this  
giorgio007

Cache Delete

Recommended Posts

giorgio007

Hi all!

What to do if while I browsing, I want to delete cache?
without error message

What should rewrite?

#cs

    Script To Clear Chromium Family browser cache ( Google chrome, Chromium, Iron... )
    Adapted of script found on <a href='http://www.winhelponline.com/blog/quickly-clear-the-google-chrome-cache-using-script/' class='bbc_url' title='External link' rel='nofollow external'>http://www.winhelponline.com/blog/quickly-clear-the-google-chrome-cache-using-script/</a>
    Customizations  To clear stored passwords and Cookies, change : $_ClearPasswordsAndCookies = 0 To $_ClearPasswordsAndCookies = 1

#ce

$_ClearPasswordsAndCookies = 0
$WshShell = ObjCreate ( "WScript.Shell" )
$objFSO = ObjCreate ( "Scripting.FileSystemObject" )
$_DirtyFlags = 0
$_Msg1 = "Google Chrome cache is cleared !"
$_Msg2 = "Google Chrome cache could not be cleared !"

If @OSVersion = "WIN_XP" Then
    $_CacheLoc = $WshShell.ExpandEnvironmentStrings ( "%USERPROFILE%" ) & "\Local Settings\Application Data\Google\Chrome\User Data\Default"
Else ; vista, seven
    $_CacheLoc = $WshShell.ExpandEnvironmentStrings ( "%LocalAppData%" ) & "\Google\Chrome\User Data\Default"
EndIf
If FileExists ( $_CacheLoc ) Then
    If ProcessExists ( 'Chrome.exe' ) Then Exit Msgbox ( 0, 'Exiting', 'Google Chrome Not close' & @CRLF & @CRLF & 'Close your Chrome browser first !' & @CRLF )
Else
    $_CacheLoc = StringReplace ( $_CacheLoc, 'Google\Chrome', 'Chromium' ) ; if not chrome user try chromium user.
    If Not FileExists ( $_CacheLoc ) Then Exit Msgbox ( 0, 'Exiting', 'Google Chrome Not found' & @CRLF & @CRLF & 'And Chromium browser Not found too ! ' & @CRLF )
    If ProcessExists ( 'Chromium.exe' ) Or ProcessExists ( 'iron.exe' ) Then Exit Msgbox ( 0, 'Exiting', 'Chromium Not close' & @CRLF & @CRLF & 'Close your Chromium or Iron browser first !' & @CRLF )
EndIf

$_CacheSize = Round ( DirGetSize ( $_CacheLoc & '\Cache' ) / 1024 /1024 )
Msgbox ( 0, 'Found', 'Cache Directory Size : ' & $_CacheSize & ' MB', 3 )

If $objFSO.FolderExists ( $_CacheLoc ) Then
    $objFolder = $objFSO.GetFolder ( $_CacheLoc )
    $colFiles = $objFolder.Files
    For $objFile in $colFiles
        If $_ClearPasswordsAndCookies = 0 Then
            If $objFile.Name <> "Current Session" And $objFile.Name <> "Current Tabs" And $objFile.Name <> "Cookies" And $objFile.Name <> "Bookmarks" And $objFile.Name <> "Preferences" And $objFile.Name <> "Web Data" Then $objFSO.DeleteFile ( $objFile )
        Else
            If $objFile.Name <> "Current Session" And $objFile.Name <> "Current Tabs" And $objFile.Name <> "Preferences" And $objFile.Name <> "Bookmarks" Then $objFSO.DeleteFile ( $objFile )
        EndIf
        If @error <> 0 Then $_DirtyFlags = 1
    Next
    If $objFSO.FolderExists ( $_CacheLoc & "\cache" ) Then $objFSO.deletefolder ( $_CacheLoc & "\cache" )
    If @error <> 0 Then $_DirtyFlags = 1
    If $_DirtyFlags = 1 Then
        Msgbox ( 0, 'Error', $_Msg2, 5 )
    Else
        Msgbox ( 0, 'Success',  $_Msg1, 5 )
    EndIf
EndIf

Exit
Edited by giorgio007

Share this post


Link to post
Share on other sites
Melba23

giorgio007,

Welcome to the AutoIt forums. :)

I have started a new thread for you - please do the same rather then necro-post in future. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
giorgio007

I understand, and thank you, but I want to use the script.

Unfortunately, I do not know what to rewrite...
I can't use while browsing, cause script send me error message.

Share this post


Link to post
Share on other sites
giorgio007

Really works! :) 

Thank U MBALZESHARI

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.