In the last post (gosh has it been that long ago?) Blasting the blasted Outlook Secure Temporary file folder… I outlined a number of free utilities that would assist with deletion of the contents of that folder.
The user who had the issue leading us on this learning adventure eventually called back with the same problem again. Additional monitoring of the user as well as the processes she was doing illustrated to me that some kind of Outlook error and/or interaction with Voltage was causing the opened attachments to remain “orphaned” even when closed out “properly.”
We then were faced with deploying one of the solutions noted. I was leaning heavily towards OutlookTempCleaner and calling it at startup via a scheduled task or simple bat-file in the Startup folder.
However, in the end, the suggestion was made to just do a batch-file that cleaned it up without any additional third-party code. OK, I’m game.
There were a number of approaches I could have taken, primarily just making a direct, hard-coded identification to the user’s particular Outlook Secure Temporary file folder location, but if that “randomly” generated location ever got changed, say if Outlook had to be reinstalled, then it might break.
Instead after a bit of research I found a suggested solution offered by GuruGary in this Experts-Exchange post: Outlook Secure Temp Folder Full : outlook, folder, temp, secure.
For a solution how about this in a batch file (that can be run as a scheduled task, or at logoff, etc.:
@echo off
for /f "tokens=3 delims= " %%a in ('reg.exe query hkcu\Software\Microsoft\Office\11.0\Outlook\Security /v OutlookSecureTempFolder ^|findstr REG_SZ') do rd "%%a" /q /s
Depending on which version of Outlook she is running, you may need to change the 11.0 in the registry key.
However, try as hard as I could in testing, it just didn’t seem to execute correctly.
It was very clever; using the reg.exe utility to query the registry and obtain the key value holding the actual path to the user’s Outlook Secure Temp folder location, then doing a deletion of it.
I then proceeded to rework the batch file using Rob van der Woude’s link: Batch files - Reading NT’s Registry with REG.EXE.
In the end I crafted the following batch file that did work perfectly on our own XP Pro SP3 systems for the problem at hand.
@ECHO OFF
::Place batch file in C:\Windows\32 location so it can find the reg.exe utility.
::Place shortcut to this batch file in the user's Startup folder to run upon login.
::Will auto-clean the user's Outlook Secure Temporary File folder location of all "orphaned" files so gets a clean-slate.
::Queries registry location of that folder location, then uses information to delete all the files present.:: Note: delims is a TAB followed by a space
FOR /F "tokens=2* delims= " %%A IN (' REG QUERY "HKCU\Software\Microsoft\Office\11.0\Outlook\Security" /v OutlookSecureTempFolder') DO SET Location=%%B
DEL /s /f /q "%Location%\*.*"
Depending on which version of Outlook you have, you will have to modify the “11.0” number according to this Microsoft Support article 817878 --Attachments remain in the Outlook Secure Temporary File folder when you exit Outlook 2003 or Outlook 2007.
Yes, just having the end user periodically run a free utility when needed probably was much easier, but this will run almost silently in the background at each login and clean things out. Also, because it queries the actual registry key location each time before running, if that does ever get changed, it can adjust, rather than had I simply “hard-coded” that specific path to begin with.
Rob’s website contains a wealth of detailed and helpful information for CLI junkies and batch-file writers:
He also has lots of great WMI Scripting information as well as an added bonus: Getting Started with WMI Scripting
Wayne Martin has another collection of lots of useful command-line models over at his WWoIT – Wayne’s World of IT blog.
- WWoIT – Wayne’s World of IT: Command-line - post tag.
- WWoIT – Wayne’s World of IT: Useful command-lines – Part I
- WWoIT – Wayne’s World of IT: More useful command-lines – Part II
- WWoIT – Wayne’s World of IT: More useful command-lines – Part III
Lots of inspiring commands and operations here…
Cheers.
--Claus V.