Close all Outlook pst files automatically.

Posted on 2009-02-22
Last Modified: 2012-05-06
I want to close outlook pst files that remain open (users lock their session instead of closing it) before backup. Backup fails everytime a pst file is open. The status is corrupt. How I can force (script or gpo) the file to be closed prior to my backup.

Question by:hamda000
    LVL 76

    Expert Comment

    by:David Lee
    Hi, hamda000.

    "How I can force (script or gpo) the file to be closed prior to my backup."
    You can't force a PST file to close while Outlook is still open.  The only solution is to close Outlook itself.  

    Author Comment

    What I meant is to force Outlook itself to close so I can't have a fail backup with corrupt pst files.
    LVL 76

    Accepted Solution

    You can do that with a bit of scripting (below), so long as the script is run in the context of the logged in user.  However, when Outlook goes to shut down it will prompt the user to empty Deleted Items if Outlook is configured to empty Deleted Items on exit.  The prompt would prevent Outlook from shutting down until someone responds to it or unless you have a utility that will watch for that dialog-box and click the button for you.
    Dim olkApp
    On Error Resume Next
    Set olkApp = GetObject(,"Outlook.Application")
    If TypeName(olkApp) <> "Nothing" Then
    End If
    Set olkApp = Nothing

    Open in new window


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now