Home
»
Discussion Forums
»
Scripts & Agent Procedures
»
Clean up outlook temp files
Subscribe via RSS
Share this
Similar Posts
Temp File Cleaning
by
LegacyPoster
on
Oct 4, 2008
Cleaning Temp Files/Automation Question
by
MollyRSnyder
on
Apr 20, 2016
Not Answered
temp files
by
LegacyPoster
on
Feb 19, 2009
Temp Cab Files
by
mikey090tx
on
Oct 22, 2018
BUDR Temp Files
by
kmullen
on
Jun 2, 2011
View More
Details
10
Replies
0
Subscribers
Posted
over 11 years ago
Scripts & Agent Procedures
Clean up outlook temp files
Posted by
LegacyPoster
on
Mar 14, 2008 2:25 AM
I have the following macro below to clean up outlook temp files. I am wondering if there is a way to have this done via a kaseya script.
Thanks
Private Sub Application_Quit()
Dim objFSO As Object, _
objTempFilesFolder As Object, _
objFolder As Object, _
strProfilePath As String
strProfilePath = Environ("USERPROFILE")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTempFilesFolder = objFSO.GetFolder(strProfilePath & "\Local Settings\Temporary Internet Files")
For Each objFolder In objTempFilesFolder.SubFolders
If Left(objFolder.Name, 3) = "OLK" Then
objFSO.DeleteFile objFolder.Path & "\*.*", True
End If
Next
Set objFolder = Nothing
Set objTempFilesFolder = Nothing
Set objFSO = Nothing
End Sub
Legacy Forum Name: Clean up outlook temp files,
Legacy Posted By Username: pinadmin
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 21, 2008 9:15 PM
I'm unaware of any Outlook temp files....
Do you mean Internet temp files?
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: jasonb
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 21, 2008 9:18 PM
When you open an attachment in outlook they are stored in a temp file under temp internet files. But when you clean up the temp internet files this does no get cleaned up. If you open a lot of attachments from within outlook the folder gets large and have to clean it up manually. I am hoping that a script can be done to help clean out this area.
Thanks
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: pinadmin
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 21, 2008 11:07 PM
Of course you can. Create a Kaseya script that uploads your VBS file (Write file) to the temp folder, then use Execute Shell Command to run it. If you also add logging to your script, you can import a text file result to the script log or just write and entry to the script log such as "Outlook cleanup completed". You may even want to insert a directory size command in your VBS before you clean it so you can report "250mb cleaned up in Outlook temp files" or something more informative like that.
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: elehman@computronixusa.com
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 21, 2008 11:37 PM
Okay I understand that but has anyone attempted this. I was wondering before trying to create it from scratch. I am ok on the scripting but thought this migt be above me a bit.
Thanks
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: pinadmin
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 22, 2008 12:31 AM
We run a lot of scripts like this...go for it!
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: rhayes@expertnetsolutions.com
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 26, 2008 11:26 PM
You will need to create a batch file that deletes the files in the temp folder.
My batch file is called
del_outlook_nettemp_files.cmd
Script Name: Change Outlook 2007 Temp Folder
Script Description: This script moves the outlook folder from default and creates a temp folder on the root.
This script also checks to see if the folder exists and delete the files stored in the temp directory path.
IF Check Registry Value
Parameter 1 : HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security\OutlookSecureTempFolder
not = :c:\nettemp
THEN
Write Script Log Entry
Parameter 1 : Changing Registry Temp Folder
OS Type : 0
Set Registry Value
Parameter 1 : HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\OutlookSecureTempFolder
Parameter 2 : c:\nettemp
Parameter 3 : REG_SZ
OS Type : 0
Write Script Log Entry
Parameter 1 : Creating c:\nettemp Folder
OS Type : 0
Write File
Parameter 1 : c:\temp\create temp outlook folder.cmd
Parameter 2 : VSASharedFiles\Create Temp Outlook Folder.cmd
OS Type : 0
Execute File
Parameter 1 : c:\temp\create temp outlook folder.cmd
Parameter 2 :
Parameter 3 : 0
OS Type : 0
Write Script Log Entry
Parameter 1 : Temp Folder Created
OS Type : 0
ELSE
Write File
Parameter 1 : c:\temp\del_outlook_nettemp_files.cmd
Parameter 2 :
OS Type : 0
Execute File
Parameter 1 : c:\temp\del_outlook_nettemp_files.cmd
Parameter 2 :
Parameter 3 : 0
OS Type : 0
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: netprotect
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 26, 2008 11:29 PM
Can you sow a sample of your batch file?
Thanks
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: pinadmin
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Mar 28, 2008 9:08 PM
I created this script a few days ago for Outlook 2003. It can be duplicated and changed for other version. I haven't copied and adjusted for other versions yet but you can get the idea from this one on how to change it.
Script Name: Clean Outlook Secure Temp Folder
Script Description: Cleans out the Outlook Secure Temp Folder. Build up can cause attachment opening issues.
IF Check Registry Value
Parameter 1 : HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\OutlookSecureTempFolder
Exists :
THEN
Get Variable
Parameter 1 : 0
Parameter 2 : HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\OutlookSecureTempFolder
Parameter 3 : path
OS Type : 0
Execute Shell Command
Parameter 1 : del "#path#*.*" /S /Q
Parameter 2 : 0
OS Type : 0
Write Script Log Entry
Parameter 1 : Outlook Secure Temp Cleaned
OS Type : 0
ELSE
Write Script Log Entry
Parameter 1 : System does not have Outlook 2003
OS Type : 0
Hope this helps
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: WayneL@P-Connect.com
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Jun 17, 2008 12:31 PM
I set out to create a script to do the same thing, which I have posted below. However, I realized that this is only useful for Outlook 2003. Outlook 2007 seems to automatically put the temp folder under local settings\temporary internet files, so the script will be less useful as time goes on. Still, it's handy for our users out there who still have 2003.
Script Name: Clean Outlook Temp folder
Script Description:
IF Test File
Parameter 1 : C:\Program Files\Microsoft Office\Office11\outlook.exe
Exists :
THEN
Get Variable
Parameter 1 : 0
Parameter 2 : HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\OutlookSecureTempFolder
Parameter 3 : OutlookSecureTempFolder
OS Type : 0
Execute Shell Command
Parameter 1 : del /F /Q "#OutlookSecureTempFolder#\*.*"
Parameter 2 : 1
OS Type : 0
ELSE
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: matcomm
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Dec 4, 2008 10:57 PM
to make it work for all offices:
read HKEY_LOCAL_MACHINE\Software\Classes\outlook.Application\CLSID\
and put it in #clsid# then read HKEY_LOCAL_MACHINE\Software\Classes\CLSID\#clsid#\ProgID\
here is the internal version number of the office app installed(works after 97)
i have a script that writes the value to a file like this:
for /f "tokens=1-3 delims=." %a IN ("#id#") DO echo %c.0 1>> #temp#\#prod#.id
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: brainpower
You have posted to a forum that requires a moderator to approve posts before they are publicly available.