Unable to open Excel Com object with powershell in scheduled task (but only while powerpoint is open)

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

excel
powershell
windows-10
scheduled-tasks
asked on Stack Overflow May 10, 2017 by user2711915

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0