Startup Script Batch File for Outlook Error "Can’t Create file: file.xxx. Right-click the folder….."
Posted on October 22nd, 2008 |
Here is a very simple batch file that can be added to the network logon script in Active directory or simply in your startup folder in windows if you or your end users frequently run into this error:
@echo off
ECHO Deleting Outlook 2003 temporary files
cd %userprofile%/local settings/temporary internet files/olk*
if errorlevel 1 goto end
del *.* /s /f /q
:end
exit
Batch file available here. (right-click, save as)
This batch file will simply navigate to the current user’s temporary Outlook folder and delete all the files in the root and sub-folders. Just be careful you don’t miss the %userprofile% variable, otherwise that command will delete all the files that happen to be in the current folder which is probably just the root of the user profile.
Original post found here.
Update 1/6/2009: Big thanks to Mark suggesting some error handling to make sure you don’t accidentally wipe the current directory if the change directory command doesn’t take place. I’ve updated the code snippet and example batch file with his suggestions.

2 Responses
in the case that the cd does not work (ie the directory does not exist), you wouldnt want the rm *.* to execute. I added a few lines to protect against this.
@ECHO OFF
ECHO Deleting Outlook 2003 temporary files
cd %userprofile%/local settings/temporary internet files/olk*
if errorlevel 1 goto end
del *.* /s /f /q
:end
exit
Thanks for the great addition Mark! I’ll put an update out to reflect the changes.