Friday, 15 June 2007

How to delete Outlook temporary files

Outlook* caches file attachments to %userprofile%\Local Settings\Temporary Internet Files\OLKnnn (where nnn is a random number). If you're a system administrator and you can connect to the user's c$ share then it's no problem to empty this folder, e.g. in the fairly common scenario where a user cannot view embedded attachments (a.k.a. Red-X syndrome).

* 2003 and earlier - for instructions for Outlook 2007 see my new post here.  Outlook 2000 before SR1 kept temporary files in %temp%.

But what do you do if you can't get a connection to the user's machine? Direct the user to their Temporary Internet Files folder and most likely they won't be able to see the folders underneath due to Windows' clever (?) obfuscation. (The slightly off-topic article has an explanation of this in the introduction.)

Short of writing a script and somehow getting that across to the user, I haven't found a better way of doing this than through the command prompt. Here are my preferred instructions, but let me know if you can suggest improvements!

[Update 4-Jul-2007: I forgot when I wrote this that the file locations changed for Windows Vista - for updated instructions, see my new post here]

  1. Start > Run > Type "cmd" (without the quotes) > Click OK

    In the command line, type the commands in bold (excluding my numbering and hitting return after each line)

  2. cd "%userprofile%\local settings\temporary internet files"

  3. dir /ad

    You should now see a list of folder names - one or more will begin with OLK.

  4. cd olk*

    This should make the first OLK folder the current directory - type the full folder name instead of OLK* to select a different one)

  5. explorer .

Note the space before the "."

This will bring up a Windows Explorer window showing the contents of the folder which you can then delete, but only after you've checked the address bar to make sure you're in the right folder!

If there was more than one OLK folder you can get to it by typing "cd.." at the command prompt then repeating steps 3 and 4 to select the OLK folder with the next folder name.

Type exit in your command window to close it, or just click on the x when you're done.


  1. WE are using Outlook 2000 without any updates. Where are the temporary folders? There are no OLK folders on any computer and all use O2K.

  2. Hi BillW

    Before Outlook 2000 SR1/1a the files were just put in your Temp folder. To find this, just do Start > Run > "%temp%" (without the quotes).

    This had to be changed because having it always in the same location was a security hole that could easily be exploited by virus writers.



  3. Thanks for the "explorer ." tip; saved my day!

  4. This batch file will perform the task for you automatically... enjoy.

    Written by Giovanni Heward


    @echo off
    setlocal enabledelayedexpansion
    for /f "tokens=5 delims=\" %%f in ('reg query hkcu\software\microsoft\office^|findstr "[0-9][0-9][.][0-9]"') do (
    call :ver %%f
    goto :eof

    for /f "skip=2 tokens=2 delims=:" %%f in ('reg query hkcu\software\microsoft\office\%1\outlook\security /v outlooksecuretempfolder') do (
    set var=%systemdrive%%%f
    if exist "!var!" (
    echo Found: %1
    echo Folder: !var!
    echo Cleaning...
    rd "!var!" /s /q
    echo Done!
    ) else (
    echo Folder !var! found in registry does not exist, skipping.

  5. Easier way:

    1. Open the attachment from the email (in my case, a PDF).
    2. Choose the "Save As" option from the program.
    3. In the dialog that opens, click on the "Save in" list at the top of the dialog box.
    4. Navigate to the folder ABOVE the one in which the temp files are stored.
    5. Right click the folder that you were just in (the temp folder) and choose "Open in new window"
    6. Select all the files.
    7. Tap the delete key. VOILA!


Creative Commons License This work by TechieBird is licensed under a Creative Commons Attribution-No Derivative Works 2.0 UK: England & Wales License.