📊 VBA (Excel)

List Files in The Windows Internet cache (INetCache) (VBA)

Lists every file in the Windows Internet cache (INetCache) with size and last-modified date directly on the active worksheet, using Scripting.FileSystemObject.

By WindowsScripting.com · 1.1 KB
BrowserCacheListFiles.bas
Attribute VB_Name = "BrowserCacheListFiles"
Option Explicit

Public Sub BrowserCacheListFiles()
    Dim fso As Object
    Dim folder As Object
    Dim f As Object
    Dim folderPath As String
    Dim ws As Worksheet
    Dim r As Long

    folderPath = Environ("LOCALAPPDATA") & "\Microsoft\Windows\INetCache"

    Set fso = CreateObject("Scripting.FileSystemObject")

    If Not fso.FolderExists(folderPath) Then
        MsgBox "Folder not found:" & vbCrLf & folderPath, vbExclamation
        Exit Sub
    End If

    Set ws = ActiveSheet
    ws.Cells.Clear
    ws.Cells(1, 1).Value = "File Name"
    ws.Cells(1, 2).Value = "Size (KB)"
    ws.Cells(1, 3).Value = "Last Modified"
    ws.Rows(1).Font.Bold = True

    Set folder = fso.GetFolder(folderPath)
    r = 2
    For Each f In folder.Files
        ws.Cells(r, 1).Value = f.Name
        ws.Cells(r, 2).Value = Format(f.Size / 1024, "#,##0.0")
        ws.Cells(r, 3).Value = f.DateLastModified
        r = r + 1
    Next f

    ws.Columns.AutoFit
    MsgBox (r - 2) & " file(s) listed from " & folderPath, vbInformation
End Sub