Client Management Suite

 View Only

Using Wisescript and NS to Cleanup OLK files 

Aug 30, 2010 03:53 PM

The Problem:

You exit any version of Microsoft Office Outlook while e-mail attachments are open. These attachments are from e-mail messages that are in a secure Outlook folder, or maybe Outlook just crashes unexpectedly. Regardless, when this occurs, the attachments you had open get orphaned in the "Outlook Secure Temporary File" folder. This happens even if you close the attachments after you exit Outlook. Also, if you open the attachment to the e-mail message from the Outlook preview pane, you do not receive a prompt to save changes when you exit Outlook.
 
Over time if this happens with the same filename, (such as for voicemails that come through your messaging system) then you will receive an error message saying that it can't create the file. It suggests you need to check your permissions on the folder you want to the save the file in. Additionally some see this as a security risk to have files from e-mail "orphaned" in this temp folder.
 
The problem occurs because Outlook 2003 and beyond cannot remove the temporary file or dispose of the secure temporary folder while the attachments are still open.


The First Solution:

When we first encountered this problem 5 years ago, we created a wisescript that would enumerate all the users that had a profile on the computer and then delete the Temporary Internet folders that had OLK in the name. We then setup a task to run this wisescript every week to delete the files. Here's a sample of what this WiseScript looked like.

The problem is back!

This solution seemed to work pretty well, but then over time we started to see a rise in helpdesk tickets that had this issue. After digging into it we found a few issues, but one of them is that the previous script from five years ago worked great with Outlook 2003, but with most of our computers having been upgraded to Outlook 2007 it was no longer cleaning the folder where Outlook 2007 stored these temporary files.
 
When you open file attachments that are considered safe, Outlook 2003 and beyond puts these attachments in a subdirectory under the Temporary Internet Files directory as an additional precaution. When Outlook first tries to use a temporary file, it examines the registry to determine whether a value exists and if the value has a valid path outlook use that location for its temporary files. That path is as follows:

 
Outlook 2010
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security
Value Name: OutlookSecureTempFolder
 
Outlook 2007
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security
Value Name: OutlookSecureTempFolder
 
Outlook 2003
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
Value Name: OutlookSecureTempFolder

If the value doesn't exist in the above registry key or the path doesn't exist, then Outlook creates a new subdirectory under the Temporary Internet Files directory and puts the temporary file in the new subdirectory. The name of the new subdirectory is unknown, is randomly generated, and takes on the following form, depending on your version of Outlook.
 
Outlook 2003
C:\Documents and Settings\username\Local Settings\Temporary Internet Files\OLKxxx
In this example, username is the user name that is used by the person who is currently logged on to the computer, and xxx is a randomly generated sequence of letters and numbers. This is what we were previously relying upon. With Outlook 2007 and 2010 being released it's time to update our scripts.
 
Outlook 2007
C:\Documents and Settings\username\Local Settings\Temporary Internet Files\xxxxxxxx
Note in Windows Vista, the temporary file resides in the following location:
C:\Users\username\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\xxxxxxxx
In this example, username is the user name that is used by the person who is currently logged on to the computer, and xxxxxxxx is a randomly-generated sequence of letters and numbers.
 
Outlook 2010
C:\Documents and Settings\username\Local Settings\Temporary Internet Files\xxxxxxx

Note that in Windows Vista and in Windows 7, the temporary file resides in the following location:
C:\Users\ username \AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\xxxxxxx

What this means is that instead of just checking all users for a temporary internet folder that has OLK in it, we might need to check up to 6 locations for each user.
 
1 - The Outlook 2010 registry location
2 - The Outlook 2007 registry location
3 - The Outlook 2003 registry location
4 - The Outlook 2003 temporary internet files location that we already were checking
5 - The Outlook 2007 and 2010 temporary internet files location
6 - The Outlook 2007 and 2010 temporary internet files location when running Vista/Windows 7


The next solution:

Instead of cleaning all locations, we found that on most of our computers the path is specified and valid for Outlook 2007 and 2010. So a script that takes care of locations 1,2,3,4 and 6 from the above list would probably be best. In order to do this for Windows XP and Windows Vista/7 there really needed to be two paths, one for each OS type.
 
So for Windows XP the script, first it completes step four listed above. Next it completes steps 1, 2, 3. However the issue with that is that each location is stored in the HKEY Users section of the registry. That section of the registry is only loaded when that user is logged in. However with a little scripting we enumerated through each on the box and then loaded that section of the registry, grabbed the key and then unloaded that section of the registry. Once we had the location we were able to delete the files.


For Windows Vista/7 we just need to execute step 6, since it's standardized on that OS type. For that we just deleted the content.Outlook folder for each user, using the same type of user enumeration that we did for XP.


 
Once that was completed, we just created a job set to run regularly that will delete those pesky OLK files and in turn reduce the number of support tickets generated. I've attached the wisescript and I hope it can help you to reduce some ticket counts also.

 

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
zip file
Clean-Up OLK Only.zip   1 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Comments

Sep 13, 2010 12:24 PM

Excellent post dude

Related Entries and Links

No Related Resource entered.