Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How To Delete All Outlook Secure Temp Folder

Posted on 2009-07-13
11
Medium Priority
?
1,844 Views
Last Modified: 2012-05-07
Hi,

The script below is what we run from our GPO at logoff, it removes the contents of the "OutlookSecureTempFolder". This works great, however our audit team want us to go further with this. is there a way to modify this script so that it searches all the user reg keys (not just the hkcu) to remove ALL "OutlookSecureTempFOlder"s for any user who has ever logged onto that PC and has this reg key present?
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oReg = GetObject("winmgmts:root/default:StdRegProv")
 
Const HKCU = &H80000001
 
oReg.EnumKey HKCU, "Software\Microsoft\Office", aKeys
 
For Each sKey in aKeys
oReg.GetStringValue HKCU, "Software\Microsoft\Office\" & sKey & _
"\Outlook\Security", "OutlookSecureTempFolder", sOutSecTmp
If Not IsNull(sOutSecTmp) Then
If Len(sOutSecTmp) > 3 Then
oFSO.DeleteFile oFSO.BuildPath(sOutSecTmp,"*.*"), True
End If
End If
Next

Open in new window

0
Comment
Question by:klwn
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24838163
Hi, klwn.

I don't believe that's possible.  The registry keys of the other users aren't loaded.  They are only loaded when that user logs on.
0
 

Author Comment

by:klwn
ID: 24838185
ah, so the script cant search the hkey_users part of the registry to get this variable for other users who have logged onto that pc? I assumed all users who logged on had this key stored in the registry?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24838210
HKEY_USERS is, I believe, all users.  In other words, they are settings that apply to all users of the computer, not the individual settings for each user of the computer.  HKEY_CURRENT_USER are the settings for the currently logged on user.  As each user logs on their personal settings are loaded into HKCU.  If HKU contained the settings of each individual user and the current user could access them, then there wouldn't be any security in the system since every user could access every other user's settings.
0
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
LVL 9

Accepted Solution

by:
dlb6597 earned 2000 total points
ID: 24839127
something like this could possibly be used as a machine startup script (I didn't test it as such)???

It enumerates each NTUSER.dat in C:\documents and settings, loads each hive in HKLM\TEMP, runs your vbscript (slightly modified for registry path differences), then unloads the user hive...

for /f "delims=" %i in ('dir ntuser.dat /s /ah /b') do reg load HKLM\temp "%i" && cscript delsecfolder.vbs && reg unload HKLM\temp

it seems to work from a command line (for the hives that are not in use) , SHOULD work as a startup script. I'm assuming all your users don't have admin permissions, so this couldn't be ran as a logon/logoff script...
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oReg = GetObject("winmgmts:root/default:StdRegProv")
 
Const HKLM = &H80000002
 
oReg.EnumKey HKLM, "TEMP\Software\Microsoft\Office", aKeys
 
For Each sKey in aKeys
oReg.GetStringValue HKLM, "TEMP\Software\Microsoft\Office\" & sKey & "\Outlook\Security", "OutlookSecureTempFolder", sOutSecTmp
If Not IsNull(sOutSecTmp) Then
If Len(sOutSecTmp) > 3 Then
oFSO.DeleteFile oFSO.BuildPath(sOutSecTmp,"*.*"), True
End If
End If
Next

Open in new window

0
 

Author Comment

by:klwn
ID: 24839235
thanks dlb6597, nice scripting!

I could indeed load this at startup on each PC, I fear this script will take a while to search for ntuser.dat /s. Can I (actually you) get the script to be more specofoc and only search the root folder for each that exists in "C:\Documents and settings"? i.e. output all the folders that exist in documents and settings and then do the ntuser.dat search in thos folders only?

many thanks already though..this could be a winner!
0
 
LVL 9

Expert Comment

by:dlb6597
ID: 24839255
alternatively you could have our startup script "CD c:\documents and settings"
0
 
LVL 9

Expert Comment

by:dlb6597
ID: 24839434
or add ... in ('dir c:\docume~1\ntuser.dat...
0
 

Author Comment

by:klwn
ID: 24859611
hi, thanks for reply.

Sorry, I am not that great with vbs scripts. Should i put the :-

for /f "delims=" %i in ('dir ntuser.dat /s /ah /b') do reg load HKLM\temp "%i" && cscript delsecfolder.vbs && reg unload HKLM\temp

in a seperate vbs script?
0
 
LVL 9

Expert Comment

by:dlb6597
ID: 24862078
that is a dos command, so it would simply be in a .cmd or .bat file...and you have all the variables be %%i in a batch file (2 percent signs preceding any variable...)
0
 

Author Closing Comment

by:klwn
ID: 31602746
Thanks v much for your time, this works perfectly!
0
 

Expert Comment

by:Wirie1980
ID: 32858724
I'm new at scripting. If I start this script the folowing error acures:
line 8
Char 1
error object is not an collection
code 800a01c3
Source MS VBscript runtime error

Can you help me implement this script?
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question