Delete Outlook 2010/2013 Temp Files on Boot

I recently needed to have to delete both Outlook 2010 and 2013 temp files on boot in Windows 7 and 8. While not planning an in-depth tutorial, I’ve decided to put both the batch code here in case anyone else needs it. There’s one for each, and if the path isn’t found in the registry it shouldn’t run anything. But keep in mind that these commands delete entire directories, so use at your own risk. I run them back to back because of deployments of both versions of Office in our environment.

Outlook 2010

FOR /F “usebackq tokens=2,* skip=2” %%L IN (
     `reg query “HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security” /v OutlookSecureTempFolder`
) DO SET OutlookSecureTempFolder2010=%%M
if defined OutlookSecureTempFolder2010 (
     echo OutlookSecureTempFolder2010 = %OutlookSecureTempFolder2010%
     attrib %OutlookSecureTempFolder2010% -R /s
     del %OutlookSecureTempFolder2010% /s /q
     mkdir %OutlookSecureTempFolder2010%
) else (
     echo:
)

Outlook 2013

FOR /F “usebackq tokens=2,* skip=2” %%L IN (
     `reg query “HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Security” /v OutlookSecureTempFolder`
) DO SET OutlookSecureTempFolder2013=%%M
if defined OutlookSecureTempFolder2013 (
     echo OutlookSecureTempFolder2013 = %OutlookSecureTempFolder2013%
     attrib %OutlookSecureTempFolder2013% -R /s
     del %OutlookSecureTempFolder2013% /s /q
     mkdir %OutlookSecureTempFolder2013%
) else (
     echo:
)

Leave a Reply

Your email address will not be published. Required fields are marked *