Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 433235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:09:14+00:00 2026-05-12T20:09:14+00:00

Currently working on a VBScript to automate some of the dirty PST ingestion work

  • 0

Currently working on a VBScript to automate some of the dirty PST ingestion work I do, and I’ve found something problematic after upgrading from Outlook 2003 to 2007.

(Had to upgrade to get around a RTF Body issue in OL2003 ..)

Even after you instruct Outlook to close the PST store, Log off and then destroy the object (set objNS = Nothing, etc.), Outlook still hangs around for 1-30 seconds depending on the size of the PST files I’m working with.

I can easily workaround and put in a delay (Wscript.Sleep(300)) but I find this dirty and don’t trust it completely … any ideas on how to get Outlook to close properly?

I have also tried polling for the instance via GetObject() but it seems that it returns False even when OUTLOOK.EXE is still visible in Task Manager.

Code I’m using below:

Function TestPSTInOutlook(strFileName)
' Open PST in Outlook then closes it, primarily to determine
' if Outlook has any difficulty in processing the PST in the
' first place.  Not interested in corruptions per message, just
' PST-wide (and passwords).

    Const olMailItem = 0
    Const olMSG = 3
    Const olDiscard = 1

    On Error Resume Next
    Dim objOL       ' Outlook.Application   
    Dim objNS       ' Outlook.Namespace
    Dim objFolder   ' Outlook.MAPIFolder
    Dim objIS       ' Outlook.Inspector 
    Dim objMail     ' Outlook.MailItem

    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")

    objNS.Logon
    objNS.AddStore strFileName

    If Err.Number <> 0 Then
        loggit_silent = True
        loggit("TestPSTInOutlook(): failed to open " & strFileName & " for reason: " & Err.Description)
        loggit_silent = False
        TestPSTInOutlook = False
    Else
        Set objFolder = objNS.Folders.GetLast
        objFolder.Name = strFileName

        Set objMail = objOL.CreateItem(olMailItem) 
        Set objIS = objMail.GetInspector 

        objIS.Close (olDiscard) 
        objMail.Close (olDiscard)

        objNS.RemoveStore objFolder
        loggit_silent = True
        loggit("TestPSTInOutlook(): success opening " & strFileName)
        loggit_silent = False
        TestPSTInOutlook = True
    End If

' BUG: Outlook 2007 refuses to shut down when told and takes its time - we have to wait otherwise we error  on trying to move the next PST file ...
' Does not exist in OL2003 but if we roll back then we don't get fixed Unicode PST support and degraded  ingestion performance
' 

    objNS.Logoff 
    objOL.Session.Logoff 
    objOL.Quit 

    Set objIS = Nothing 
    Set objMail = Nothing 
    Set objNS = Nothing 
    Set objOL = Nothing 

    Wscript.sleep(300)
End Function

NB: loggit() is purely a logging function (sends to stdout and to a debuglog.txt)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:09:14+00:00Added an answer on May 12, 2026 at 8:09 pm

    What about a function like this to see if outlook.exe is still running

    Function IsRunning(procName)
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & procName & "'")
        If colProcesses.Count > 0 Then
            request = True
        Else
            request = False
        End If
        Set colProcesses = Nothing
        Set objWMIService = Nothing
        IsRunning = request
    End Function
    

    Then you can just run a loop until the function returns false Something like this

    Do While IsRunning("notepad.exe")
    Loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently working on something which uses ajax for some pagination. What I'm looking to
Currently working with NSURLConnection. Found a great website showing important delegate methods coming with
Currently working through a Teach Yourself WPF tutorial. Usually I can mentally convert from
Im currently working with two actors in scala. One, the producer , produces some
Im currently working on a Python/Pygame module to wrap some basic sprite animation. Animation
I'm currently working on learning some game development with Java. I'm working on the
Am currently working on a web application which receives the encoded text from the
Im currently working on making a flash platformer engine...but my collision detect needs some
Were currently working on a script that reads the current users information from out
Currently working on a 2-way lookup association generic, sorted by TKey. At some point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.