none
Starting Outlook from Task Sceduler not logging Event ID45 for addin boot times RRS feed

  • Question

  • Hi everyone,

    I'm trying to automate the start up of Outlook to get a good sense of how long my add-in takes to boot on a specific system. I have a basic powershell script which I wrote to start up Outlook daily and shut down once it finishes starting up. The trouble I'm running into is that when I run the ps script itself from the integrated scripting environment, addin boot times are logged in the event viewer under Windows Applications with Event ID 45. This is exactly what I need. However... 

    When I add this script into Task Scheduler in Windows, this event is no longer logged. I still get other event ID logs (ID 30, for example) when Outlook starts, but it seems that I'm missing the add-in boot time log. Any idea what I may be doing wrong? 

    Environment: Windows 7 with Office 2010


    Wednesday, June 29, 2016 7:00 AM

Answers

  • We've fixed the issue, and for us it appears the fact that Windows updates was running (old vm snapshot) caused inconsistent behaviour in the script. After letting the VM stew overnight and finished updating, re-running the task whether on demand or based on a time-trigger is reliably producing results for us now. We also adjusted the 'timeout' period from 10 seconds (our sleep 20 below) to 20 and that may have also helped the problem. 

    Here's the bulk of the script that people might be interested in.

    New-Item C:\outlook-logging\OutlookStart.txt -type file -force

    for ($i=0; $i -le 100; $i++){

    echo "Starting Outlook Benchmark #" $i

    Start-Process Outlook.exe

    sleep 20

    $outlook = Get-Process outlook -ErrorAction SilentlyContinue

    if ($outlook){

    $outlook.CloseMainWindow()

    }

    sleep 5

    if (!$outlook.hasExited){

    $outlook | Stop-Process -Force

    }

    $logMsg = Get-EventLog application -newest 20 | where-object {$_.eventID -eq 45}

    Add-Content C:\outlook-logging\OutlookStart.txt $logMsg.Message

    Clear-EventLog Application

    }

    Thursday, June 30, 2016 3:53 PM

All replies

  • Are you certain that add-ins have been loaded when Outlook is started by your Task Scheduler initiated script?

    If you share the script we can see if the issue can be reproduced on our own systems.


     
    • Edited by RLWA32 Wednesday, June 29, 2016 10:53 AM
    Wednesday, June 29, 2016 10:52 AM
  • Hello,

    Most probably the add-in wasn't loaded at all.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

    Did you have a chance to try logging something to the event viewer using a regular Windows form application run from a task scheduler? Can you see such records?


    [custom.development]

    Wednesday, June 29, 2016 8:35 PM
  • We've fixed the issue, and for us it appears the fact that Windows updates was running (old vm snapshot) caused inconsistent behaviour in the script. After letting the VM stew overnight and finished updating, re-running the task whether on demand or based on a time-trigger is reliably producing results for us now. We also adjusted the 'timeout' period from 10 seconds (our sleep 20 below) to 20 and that may have also helped the problem. 

    Here's the bulk of the script that people might be interested in.

    New-Item C:\outlook-logging\OutlookStart.txt -type file -force

    for ($i=0; $i -le 100; $i++){

    echo "Starting Outlook Benchmark #" $i

    Start-Process Outlook.exe

    sleep 20

    $outlook = Get-Process outlook -ErrorAction SilentlyContinue

    if ($outlook){

    $outlook.CloseMainWindow()

    }

    sleep 5

    if (!$outlook.hasExited){

    $outlook | Stop-Process -Force

    }

    $logMsg = Get-EventLog application -newest 20 | where-object {$_.eventID -eq 45}

    Add-Content C:\outlook-logging\OutlookStart.txt $logMsg.Message

    Clear-EventLog Application

    }

    Thursday, June 30, 2016 3:53 PM
  • Hi b_cheng,

    Congratulation, we are glad to hear that you have resolve your issue, thanks for you sharing your solution, that will help other community when they meet same issue.

    Friday, July 1, 2016 3:07 AM