Starting Excel Interop Error 0x80070520 A specified logon session does not exist

0

We have a task which starts a PowerShell script that uses Excel Interop to extract regularly some graphs from Excel. But since updating from Win10_2004 to Win10_20H2 the following error occurs:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070520 A specified logon session does not exist. It may already have been terminated.

Part of the PowerShell-script to start Excel:

    $excelApp = New-Object -ComObject Excel.Application -Property @{DisplayAlerts = $false}

After updating to Win10_21H1 the problem still exists. Office 2016 is used with a local licensekey.

Steps already taken:

1. DCOMCNFG.exe

Go to:

    Component Service -> Computers -> My Computer -> DCOM Config -> Office Licensing COM Server 16 -> Properties -> Security -> Launch and Activation Permission

Select Customize and click on edit and add the user that runs the Application with full access

2. RegEdit.exe

Go to registry location:

    Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity

and add registry key

    EnableADAL REG_DWORD 0x00000000 (0)

3. Desktop map

Create the following 2 maps:

    %windir%\System32\config\systemprofile\Desktop
    %windir%\SysWOW64\config\systemprofile\Desktop

4. Copy EXCEL.EXE to EXCEL_COPY.EXE

Go to map C:\Program Files (x86)\Microsoft Office\Root\Office16
and copy EXCEL.EXE to EXCEL_COPY.EXE

Change registry key

    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32

from:

    C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE /automation

to:

    C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL_COPY.EXE /automation

Now everything works fine and Excel starts in an unattended task.

In this situation, after every update from Excel we have to make a manual copy to EXCEL_COPY.EXE. Which setting should we adjust so that the above copy action is no longer necessary?

excel
powershell
scheduled-tasks
asked on Stack Overflow May 20, 2021 by hdeheer28 • edited May 20, 2021 by hdeheer28

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0