2

I have had a powershell script that runs hourly as a Scheduled Task and drops some data into an excel spreadsheet.

New-Object : Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due 
to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
At
D:\path\to\myScript.ps1:534 char:10
+ $Excel = New-Object -Com Excel.Application
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

After running without issue for months the script started to fail yesterday. I have finally tracked the failure condition down to being whether or not Powerpoint is open at the time the script runs. Having Word or Excel open or not open is not a problem. Having a particular presentation open or no presentation in powerpoint makes no difference.

It does not appear to be failing to open a particular excel file, it fails at the very first stage of creating the excel object before any files are loaded.

I can run the script successfully with powerpoint open (or not open) if I run from command line, it only fails when run from the scheduled task. Either by pressing run or on the hourly automatic runs.

The jobs are set to run as me, and "run with highest privileges", and "run whether user is logged in or not". The command launched to run the program is exactly, character for character, what I have been using to test from command line (with and without powerpoint open). OS is Windows 10

user2711915
  • 2,704
  • 1
  • 18
  • 17
  • 1
    As a guess, the run if user is logged in or not, may be the issue because that makes the task run noninteractively. – BenH May 10 '17 at 17:19
  • 1
    Do you have more information in Event Log? Search for exact time in order to identify exact record. Have you tested that failure condition on another machine? Can you reboot existing machine to check if it will persist after reboot? – Igor May 10 '17 at 17:55
  • I have had a look in the event log, not really sure what is relevant. In Windows Logs -> System I found a Level: Error Source: DistributedCOM General: "The server {00024500-0000-0000-C000-000000000046} did not register with DCOM within the required timeout." created by the script failing. This doesn't seem to give much more information than the error in the original post. There are a bunch of logs in the Windows PowerShell section, but these look mundane and much the same whether the task fails or not. – user2711915 May 10 '17 at 18:29
  • I have restarted and installed updates several times: no effect. Seems to fail the same logged in or not. – user2711915 May 10 '17 at 18:35
  • Today, it seems to fail when Word is open, despite Word not being a problem yesterday. Error and log messages are the same as when it was failing when powerpoint was open. It still fails when powerpoint is open. – user2711915 May 11 '17 at 13:06

0 Answers0