Delete internet temp files on logon

Discussion in 'Scripting' started by Chris @ ecs, Sep 26, 2006.

  1. Chris @ ecs

    Chris @ ecs Guest

    I found a script to view the contents of the cach but how do I modify it to
    delete the contents of the cache?

    Const TEMPORARY_INTERNET_FILES = &H20&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
    Set objFolderItem = objFolder.Self
    Wscript.Echo objFolderItem.Path

    Set colItems = objFolder.Items
    For Each objItem in colItems
    Wscript.Echo objItem.Name
    Next
     
    Chris @ ecs, Sep 26, 2006
    #1
    1. Advertisements

  2. Chris @ ecs

    Joe Reynolds Guest

    thats overkill.

    use a simple BAT file with DEL c:\path

    in a logon script
     
    Joe Reynolds, Sep 26, 2006
    #2
    1. Advertisements

  3. Chris @ ecs

    Gino Guest

    I modified the script and ran it. And it dose delete the files in the Temp
    Internet Folder.
    But I noticed when I re-opened Internet Explorer, IE puts the files back.
    Mysterious!
    IE must cache these files somewhere else and updates Temp Internet Folder
    when it opens.

    'Create file DeleteTempInternetFiles.vbs in Notepad
    'Copy and paste this code into it.
    'Double click to run it
    'watch for line wrap
    ================================================
    Option Explicit
    Private objFileSystem
    Private objShell
    Private objFolder
    Private objFolderItem
    Private filesList
    Private TempInterFold
    Private file_
    Const temp_inter_files = &H20&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(temp_inter_files)
    Set objFolderItem = objFolder.Self

    Set objFileSystem = CreateObject("Scripting.fileSystemObject")
    Set TempInterFold= objFileSystem.getFolder(objFolderItem.path)
    Set filesList = TempInterFold.files

    For Each file_ in filesList
    objFileSystem.deleteFile(file_)
    Next

    Set objFileSystem = Nothing
    Set objShell = Nothing
    ==============================================
     
    Gino, Sep 30, 2006
    #3
  4. Chris @ ecs

    Chris @ ecs Guest

    Thanks. How about taking a peak at this one too?


    Const COOKIES = &H21&

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(COOKIES)
    Set objFolderItem = objFolder.Self



    Set colItems = objFolder.Items

    For Each objItem in colItems
    if objitem.name <> "INDEX.DAT" then

    objFSO.DeleteFile (objFolderItem.Path & "\" & objItem.name)
    end if
    Next
     
    Chris @ ecs, Oct 2, 2006
    #4
  5. Chris @ ecs

    Gino Guest

    I didn't get a chance to run this, so if you get an error try checking for
    spelling errors.
    But this is the basic script.
    This is the same script that I already gave you except the change to &H21&
    which is
    the Speacial Folder name that the OS uses to keep track of the COOKIES
    FOLDER.
    Plus within the FOR EACH Loop I nested the IF statement to exclude INDEX.DAT
    file
    from being deleted in the objFileSystem.delete(file_) line.
    ================================================
    Option Explicit
    Private objFileSystem
    Private objShell
    Private objFolder
    Private objFolderItem
    Private filesList
    Private cookies
    Private file_
    Const cookie_folder = &H21&

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(cookie_folder)
    Set objFolderItem = objFolder.Self

    Set objFileSystem = CreateObject("Scripting.fileSystemObject")
    Set cookies = objFileSystem.getFolder(objFolderItem.path)
    Set filesList = cookies.files

    For Each file_ in filesList
    if file_.name <> "INDEX.DAT" then
    objFileSystem.deleteFile(file_)
    end if
    Next

    Set objFileSystem = Nothing
    Set objShell = Nothing
    ==============================================
     
    Gino, Oct 3, 2006
    #5
    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.