HemlockPrinters
asked on
scheduled task to delete Outlook Secure Temp files
I have a script to delete outlook secure temp folder and create a scheduled tasked on domain user's machines. The problem is I have to run this scheduled task as current log on user in order to delete logon user's in Outlook Secure Temp files.
I created a doman admin user scheduler and run this scheduled task as Scheduler, the script runs but the Outlook Secure Temp files are not deleted.
I would like to delelte outlook secure temp folders using account Scheduler's credential.
How can I achieve it?
thanks,
I created a doman admin user scheduler and run this scheduled task as Scheduler, the script runs but the Outlook Secure Temp files are not deleted.
I would like to delelte outlook secure temp folders using account Scheduler's credential.
How can I achieve it?
thanks,
ASKER
Set oWSH = CreateObject("WScript.Shel l")
Set oFSO = CreateObject("Scripting.Fi leSystemOb ject")
For Each sKey in Array("11.0","12.0")
sOutSecTmp = Empty
On Error Resume Next
sOutSecTmp = oWSH.RegRead("HKCU\Softwar e\Microsof t\Office\" _
& sKey & "\Outlook\Security\Outlook SecureTemp Folder")
If Len(sOutSecTmp) > 3 Then
oFSO.DeleteFile oFSO.BuildPath(sOutSecTmp, "*.*"), True
End If
Next
Set oFSO = CreateObject("Scripting.Fi
For Each sKey in Array("11.0","12.0")
sOutSecTmp = Empty
On Error Resume Next
sOutSecTmp = oWSH.RegRead("HKCU\Softwar
& sKey & "\Outlook\Security\Outlook
If Len(sOutSecTmp) > 3 Then
oFSO.DeleteFile oFSO.BuildPath(sOutSecTmp,
End If
Next
The script works fine for me. I'm a little confused which account you're running it under. Are you running it as the current user (i.e. the person who's logged in to the computer) or under some other account?
ASKER
no, I run it under local admin (or domain admin), the script runs without error, but it doesn't delete files.
it only works (delete files) under current log in user
it only works (delete files) under current log in user
That makes sense. It's getting the path from HKCU, the current user. If the script is running under the local admin account, then it's never going to get the path you want it to. It's going to get the path for the local admin account. Why not run it under the local user account?
ASKER
the password for local user's account has to be changed in 6 months, so if I run the scheduled taske uner the local user account, once the user change the password, the task will fail
It shouldn't unless you store the password with the task which I don't believe is necessary.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
there are not other resolutions
Can you share the script so we can see for ourselves what it's doing?