I am writing a script in Excel VBA to get the thumbnails off a google images search. When trying to figure out how to clean up the temporary files made in this automated search, I stumbled upon the INetCache directory.

Further digging shows that this folder (specifically the Low\IE subdirectory) contains a huge load of images - some of these are image thumbnails, the very files I've been downloading laboriously through vba, and are already present. So I decided to investigate further by debugging through my code step-by-step and seeing what popped up in my InetCache\Low\IE directory, and when. I'm going to walk through my results and I hope to get some answers on

  • What the results mean
  • Whether I can use these files to my advantage rather than download twice (once to the cache, once with my VBA program)
  • How I should clean up this clutter from VBA

NB the internet tells me this folder is in different places depending on your system; mine is %localAppData%\Microsoft\Windows\INetCache\Low\IE with Win10 IE11, but a fairly reliable way to get there is to type


into the vba immediate window. All files are protected system files so must be made visible

My results

Here's what I found appeared in the INetCache\Low\IE folder as I ran my VBA code. I started off by renaming the existing folder to oldIE

Start the browser

Set objIE = New InternetExplorer 'requires referencing Microsoft Internet Controls
  • New IE folder created empty

Make browser visible

objIE.Visible = True
  • New container.dat file created within IE

Navigate to webpage & wait for load

objIE.Navigate "https://www.google.com/search?q=cookies&safe=off&tbs=isz:ex,iszw:1366,iszh:768&tbm=isch&source=lnt"
'google images search for "cookies"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop 'wait for load
  • 4 New subfolders created with 8 character alphanumeric (Uppercase) names
  • These contain a few generic icons (Chrome, FB, twitter), although one does contain the thumbnail of the first image result (named images[1].jpg)

Page Scroll

Google runs some Ajax script to load more images when you scroll down. My method is to scroll down until the "get more results button" is shown; this should signify that the entire page of image objects has loaded (although their thumbnail urls/strings are not yet present).

Set currpage = objIE.Document
Set myDiv = currpage.getElementById("fbar") 'this is the load more images button
Do Until elemRect.bottom > 0 'scroll until myDiv is in view
    currpage.parentWindow.scrollBy 0, 10000 'scroll by a big amount to trigger next part to load
    Set elemRect = myDiv.getBoundingClientRect
  • All 4 folders become populated with images
    • These images either have images[1-10].ext naming or images followed by an 8 character alphanumeric string
    • I'd like to know if there's a pattern here relating the filename/other property to its location on the webpage, as this would allow me to use these images in my VBA program
    • By the end of the page fully loading there are 375 jpgs & 390 images in total in the Cache, compared to 400 image results in the entire webpage
  • Random checks I did on these images in the Cache did show that they were in the IE search results (i.e., I could find them by scrolling around the image results, so I'm guessing that all the images in the Cache do come directly from the IE search results. But my checks weren't exhaustive)

I also scrolled the page manually during this time

  • Doing so created a load of new .txt files and other files. It also downloaded more images into the cache.
  • In order for this to be useful I'll need a more systematic way to get these into vba.

Counting images

imgCount = currpage.getElementById("rg_s").getElementsByTagName("IMG").Length
  • This returned 400 for the given search url. The cache contained 375 images that looked like thumbnails from the search, and a few other logos and icon images
  • A possible reason for the discrepancy is that some (usually the first 10 or so) thumbnails are base 64 encoded strings, others have urls, maybe only the ones with urls are cached (although this doesn't look like it's always true)

Quitting IE

  • This did nothing noticeable to the files in the cache

Finally, downloading image thumbnails

Public Declare Function URLDownloadToFile Lib "urlmon" _
    Alias "URLDownloadToFileA" _
    (ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) As Long

followed by

fileurl = currpage.getElementById("rg_s").getElementsByTagName("IMG")(0).src
'returns thumbnail url of first image result
strFile = Environ("Temp") & "\Temp.jpg" 'place file in temp folder
ret = URLDownloadToFile(0, fileURL, strFile, 0, 0) 'fileurl is the web url, strfile is the save location
  • Also does nothing to the images in the cache

What I want to know (TL;DR)

That's all fine and dandy, but what am I actually asking?


  • Is there a logic to the image file naming in the IE cache - or some other property that I can use to display image thumbnails in the same order as in an IE search, using these cache files?
  • If I really can't use them at all because their location/naming is totally unpredictable; how can I clear them from VBA/ stop them ever being created
    • This answer doesn't touch them, nor does Siddharth Rout's approach. I can't delete them with CreateObject("Scripting.FileSystemObject") because of protection issues, and all other methods I've found are manual and require clicking through IE menus
    • Is it safe to do so? Reddit says it is, but they're not really Superusers like you guys. And I'm planning to run this software on other people's machines so I want to check if this is something I should get rid of for release to other people.
    • I feel like it's unnecessary for all this to be downloaded in the first place anyway
  • Finally, purely out of interest, what are all the files downloaded/created for anyway?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.