Script to clear Cookies Temp Files Temporary Internet and History

Discussion in 'Scripting' started by Michael Noote, Nov 13, 2004.

  1. Please I appreciate any help to get a script that will clear cookies , temp
    files, temporary internet and history. Thanks everyone I sincerely mean this
     
    Michael Noote, Nov 13, 2004
    #1
    1. Advertisements

  2. Deletes all Cookies/History/Temporary Internet Files for every local user.
    Three line batch file (just in case the lines wrap, each line begins with FOR):

    FOR /F %%A IN ('DIR/B "C:\Documents and Settings"') DO DEL/S/Q/F "C:\Documents and Settings\%%A\Cookies\*.*"

    FOR /F %%A IN ('DIR/B "C:\Documents and Settings"') DO DEL/S/Q/F "C:\Documents and Settings\%%A\Local Settings\History\*.*"
    FOR /F %%A IN ('DIR/B "C:\Documents and Settings"') DO DEL/S/Q/F "C:\Documents and Settings\%%A\Local Settings\Temporary Internet
    Files\*.*"


    Austin M. Horst
     
    Austin M. Horst, Nov 14, 2004
    #2
    1. Advertisements

  3. Thanks alot I appreciate the help it doesnt seem to want to clear temporary
    internet files but I not going to complains thanks for all of your help and I
    cant thank you enough
     
    Michael Noote, Nov 15, 2004
    #3
  4. The line wrapped after "Internet", before "Files"

    FOR /F %%A IN ('DIR/B "C:\Documents and Settings"') DO DEL/S/Q "C:\Documents and Settings\%%A\Local Settings\Temporary Internet
    Files\*.*"

    The line is 138 characters long. In Outlook Express, the maximum line length is 132.

    Try to copy the line above again, or join the following two lines together, leaving a space between DO and DEL

    FOR /F %%A IN ('DIR/B "C:\Documents and Settings"') DO
    DEL/S/Q "C:\Documents and Settings\%%A\Local Settings\Temporary Internet Files\*.*"


    Austin M. Horst
     
    Austin M. Horst, Nov 15, 2004
    #4
  5. Michael Noote

    andy_p Guest

    Hi did you get this script to work? I am trying to write a script for the
    same thing. Let me know what the final code.. thanks!!
     
    andy_p, Jan 5, 2005
    #5
  6. Michael Noote

    andy_p Guest

    Hi did you get this script to work? I am trying to write a script for the
    same thing. Let me know what the final code.. thanks!!
     
    andy_p, Jan 5, 2005
    #6
  7. Michael Noote

    John Hobbs Guest

    I worte this script, it works for temp files, temporary internet files, and
    cookies, but I can't get it to delete history. It is long but it
    works...check it out

    'Script Created by John Hobbs, on 3/16/05

    'option Explicit
    on error resume Next
    Dim oFSO, OFolder, oSubDirs, Windir, oWShell, objShell, folder, strPath

    'Instantiate a FileSystemObject

    set oWShell = WScript.CreateObject("WScript.Shell")
    WinDir=oWShell.ExpandEnvironmentStrings("%windir%")
    Set oFSO = CreateObject("Scripting.FileSystemObject")

    '----------------------------------------------------------------------------------------------------

    Set oFolder = oFSO.GetFolder("C:\Temp")
    DelTree(oFolder)
    '----------------------------------------------------------------------------------------------------

    Set oFolder = oFSO.GetFolder("C:\"& WinDir & "\Temp")
    DelTree(oFolder)

    '----------------------------------------------------------------------------------------------------


    Set oFolder = oFSO.GetFolder("C:\Documents and settings")
    Set oSubDirs = oFolder.SubFolders 'list of each users folder in documents
    and settings

    for Each Folder In oSubDirs 'loop through each users folder
    If folder.name<>"Administrator" And folder.name<>"LocalService" And
    folder.name<>"NetworkService" And folder.name<>"All Users" and
    folder.name<>"Default User" Then
    set strPath = oFSO.GetFolder(Folder & "\Local Settings\Temporary Internet
    Files")
    DelTree(strPath)
    set strPath = oFSO.GetFolder(Folder & "\Local Settings\Temporary Internet
    Files\content.ie5")
    DelTree(strpath)
    set strPath = oFSO.GetFolder(Folder & "\Local Settings\Temporary Internet
    Files\content.mso")
    DelTree(strpath)
    End If
    Next

    '----------------------------------------------------------------------------------------------------

    Set oFolder = oFSO.GetFolder("C:\Documents and settings\")
    Set oSubDirs = oFolder.SubFolders 'list of each users folder in documents
    and settings

    For Each Folder In oSubDirs 'loop through each users folder
    If folder.name<>"Administrator" And folder.name<>"LocalService" And
    folder.name<>"NetworkService" And folder.name<>"All Users" and
    folder.name<>"Default User" Then
    'WScript.Echo folder.name
    set strPath = oFSO.GetFolder(Folder & "\Local Settings\Temp\")
    DelTree(strPath)
    'WScript.Echo strPath
    End if
    Next

    Const COOKIES = &H21&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(COOKIES)
    Set objFolderItem = objFolder.Self
    strPath = objFolderItem.Path & "\*.*"

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFile(strPath)

    Const HISTORY = &H22&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(HISTORY)
    Set objFolderItem = objFolder.Self
    strPath = objFolderItem.Path & "\*.*"
    Set colItems = objFolder.Items
    For Each objItem in colItems
    objitem.deletefolder
    ' Wscript.Echo objItem.Name
    Next
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFile(strPath)
    DelTree strpath
    DelTree strpath1



    WScript.Echo "Script has completed"


    Function DelTree(RootFolder)
    On Error Resume next
    set oFolder=oFSO.GetFolder(RootFolder) 'list of each users folder in
    documents and settings
    strall=ofolder&"\*.*"
    oFSO.DeleteFile strall
    For Each file In oFolder.Files
    oFSO.DeleteFile(file)
    next
    For Each folder In oFolder.SubFolders
    For Each file In folder.files
    oFSO.DeleteFile(file)
    'WScript.Echo Err.Description, file
    next
    if folder.size>0 then DelTree(folder)
    oFSO.DeleteFolder(folder)
    'WScript.Echo folder
    'WScript.Echo Err.Description, folder
    Next

    End Function
     
    John Hobbs, Mar 16, 2005
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.