Script/Freeware Program to Clear cache for IE7/Firefox for ALL USERS ON Windows XP

Posted on 2007-10-10
Last Modified: 2013-12-08
Hi all:

I am looking for a way to run a script that will let me clear the browser history/cache of all user profiles present on windows XP systems for BOTH IE7 and Firefox

Can anyone help me ASAP? Urgent :/

Question by:vtois
    LVL 8

    Expert Comment

    EmpTemp id freeware:

    I use it. It does require you to manually add the folders you want cleared when
    you set it up.. Note in order to see the temporary internet folder and cookies, a
    and history folders you must have "Show Hidden Files & Folder"  enabled and uncheck
    "Hide Protected Operating system folders" (temporarily)  through
    folder options in windows..

    Then you simple browse to C:\Documents & Settings\Local Settings" and add
    each of the folders to be cleared

    If you need help once you get the program installed, post and I will post more detailed
    instructions. It is pretty intuitive.

    Author Comment

    Hi Mshine:

    As I stated in my question, I need this to be a command-line solution so I can run it as a script... GUI solutions will not work, unless they support commandline feed.
    LVL 63

    Expert Comment

    I would post this in the VBS, ad MSDOS TA's since they will probably ahve the best command line solutions.

    I hope this helps !
    LVL 63

    Expert Comment

    LVL 22

    Expert Comment

    You can also try CCleaner ( which cleans out temporary files for those programs and much more but I don't think it clears the folders for all users.
    LVL 8

    Expert Comment

    EmpTemp can be commandline executed... Simply create a BAT file in the
    startup folder..

    From the EmpTemp Help:

    Command line options
    /clip makes emptemp run minimized, empty the clipboard and then terminate.
    /all makes emptemp run minimized, empty all temp folders and then terminate.
    /keepdirs prevents deleting of folders (but not their contents). Also see Options.
    The last two can be combined. The order and case of these arguments doesn't matter.
    Example: emptemp2.exe /all /keepdirs


    Author Comment

    can ccleaner be executed via cmdline in the background with no user interaction?

    yes, but it requires that I "set it up first"... Doing that to 300+ systems is not ROI-smart

    thanks for the URL but none pertain to me :/ my case is for Windows XP systems on a Windows 2003 managed domain.
    LVL 8

    Expert Comment

    Oh.. well you did not mention anything about 300 machines or a Domain.. ;O)

    I actually wrote a command line batch file.. which is run through the startup, but
    you would have to distribute the file to every machine.. It was something I worte for
    our IT department, because frankly I KNOW none of the users bother keeping their
    own machines clean and in order. I have the files at work, but in the morning I
    will post them.. Try them on one of your machines, and if they do what you want
    then this will be the cheapest way to go.. This will be just to clear the "Temporary
    Internet Files" and the "Cookies"

    Author Comment

    I look forward to the batch file mshine! :)
    LVL 8

    Accepted Solution

    Ok.. sorry for the delay but I had to refresh my memory on what I did here. It was
    a little more complicated now that I look over my files again. First I had to write a pretty
    simple program in VB which would go out and read the directory structure of the
    documents and settings folder.. Basically it would collect the names of all the different
    users setup on the machine with local accounts, where all the temp files would be stored.

    From there the executible creates the batch file which would delete the existing folders
    and it contents, and create new/empty folders in its place.

    You basically would deploy two files to each of the computers you want to clean.
    1 Batch file to the ALL USERS startup folder, and the EXECUTIBLE file to the C:

    I can zip up these files and send them to you, and if you or anyone you know
    owns VB6 (yes I am still using vb6 I have not dove into .NET yet), I can send
    the source files for the EXE file.

    The EXE file pretty much run silient, and does not use any user input so there
    are no controls and does not require INSTALLATION or RUNTIME file deployment.

    A few things you need to tell me if you cannot work on the VB source code is
    exactly what files you want to cleanup? Just Temporary Internet Files? or do
    you want History, Cookies, Temp, and you can even go further and hit the
    Windows TEMP and Download Program Files directories as well..

    If you know a basic level of VB programming you can edit the code yourself
    the do what you want it to.. or I can make the alterations in no time for you
    to suit your needs.. I suppose if I were a professional programmer I would have
    went one step further and created a CFG file so the user could set the folder
    using notepad, but that would have been more programming. I also wrote a version
    that autmatically runs Defragmenter as well... But not in the startup, instead we handled
    it using "Scheduled Tasks"

    Here is what the basic BAT & Code for VB Looks Like:
    Startup Folder BAT:


    VB Code for AutoClean.exe:

    Option Explicit

    Private Sub Form_Load()
    Static running As Boolean

    Dim AllDirs As New Collection
    Dim next_dir As Integer
    Dim dir_name As String
    Dim sub_dir As String
    Dim i As Integer
    Dim txt As String
    Dim Path As String
    Dim file_name As String
    Dim fnum As Integer
    Dim rdfront As String
    Dim mkdirfront As String
    Dim back1 As String
    Dim back2 As String
    Dim back3 As String
    Dim back4 As String

        Path = "C:\Documents and Settings"

        On Error Resume Next
        Kill "AutoClean.bat"

            next_dir = 1
            AllDirs.Add Path ' Start here.
            Do While next_dir <= 1 'AllDirs.Count
                ' Get the next directory to search.
                dir_name = AllDirs(next_dir)
                next_dir = next_dir + 1
    ' Read directories from dir_name.
                sub_dir = Dir$(dir_name & "\*", vbDirectory)
                Do While sub_dir <> ""
                    ' Add the name to the list if
                    ' it is a directory.
                    If UCase$(sub_dir) <> "PAGEFILE.SYS" And _
                        sub_dir <> "." And sub_dir <> ".." _
                        sub_dir = dir_name & "\" & sub_dir
    '**** Write  ****************
        back1 = "\Local Settings\Temporary Internet Files"
        back2 = "\Local Settings\Temp"
        back3 = "\Cookies"
        back4 = "\Local Settings\History"
        rdfront = "rd /s /q "
        mkdirfront = "mkdir "
        file_name = "AutoClean.bat"

    'Open the file.
        fnum = FreeFile
        Open file_name For Append As fnum
    'Skip check
        If sub_dir <> "C:\Documents and Settings\All Users" Then
            If sub_dir <> "C:\Documents and Settings\All Users.WINNT" Then

    ' Read the text.
            Print #fnum, rdfront & Chr(34) & sub_dir & back1 & Chr(34)
            Print #fnum, mkdirfront & Chr(34) & sub_dir & back1 & Chr(34)
            Print #fnum, rdfront & Chr(34) & sub_dir & back2 & Chr(34)
            Print #fnum, mkdirfront & Chr(34) & sub_dir & back2 & Chr(34)
            'Print #fnum, rdfront & Chr(34) & sub_dir & back3 & Chr(34)
            'Print #fnum, mkdirfront & Chr(34) & sub_dir & back3 & Chr(34)
        End If
            End If
    ' End of skip check
    ' Close the file.
            Close fnum
    '**** End Write****************

                        On Error Resume Next
                        If GetAttr(sub_dir) And vbDirectory _
                            Then AllDirs.Add sub_dir
                    End If
                    sub_dir = Dir$(, vbDirectory)
                If Not running Then Exit Do
    '**** Write End ****************

        'file_name = "AutoClean.bat"

    'Open the file.
        'fnum = FreeFile
        'Open file_name For Append As fnum

        ' Read the text.
            'Print #fnum, "rd /s /q " & Chr(34) & "C:\WINNT\Downloaded Program Files" & Chr(34)
            'Print #fnum, "mkdir " & Chr(34) & "C:\WINNT\Downloaded Program Files" & Chr(34)
            'Print #fnum, "contig -s c:\*"
    ' Close the file.
            'Close fnum
    '**** End Write****************

    Unload Form1
    End Sub

    I know this is a lot to read, but the application is quite simple, and if run daily happens
    very quickly.. Initial cleans might run a bit longer depending on how much stuff has
    to be deleted.. after the initial run.. it runs and finishes in less than 2-3 seconds..
    LVL 8

    Expert Comment

    I just realized you had Firefox listed as well... That can be programmed in, I would
    just need to knopw what folders the Firefox stores is temp files in. ;O)

    Author Closing Comment


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
    Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now