5

Error Message

ODT (Office Deployment Tool) log reported error when installing into Windows Container (Server Core): C2R client returned failing error code, error code: 17002

Environments

  • Behavior in Windows Server 2019 (1809) with Desktop Experience installed.
    • ODT installation Result: Succeeded.
    • test-o365.ps1: Succeeded.
  • Behavior in Container (mcr.microsoft.com/windows/servercore:ltsc2019)
    • ODT installation Result: Negative (C2R client returned failing error code, error code: 17002)
    • test-o365.ps1: Negative: HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)

Dockerfile

FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR C:/setup
COPY . . 
ENTRYPOINT startup.cmd

startup.cmd

curl.exe https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_12325-20288.exe  --output .\
officedeploymenttool_12325-20288.exe
officedeploymenttool_12325-20288.exe /quiet /passive /extract:.
setup.exe /configure o365.xml
powershell -file test-o365.ps1
pause

o365.xml

<Configuration>
  <Add OfficeClientEdition="64" Channel="Monthly">
    <Product ID="O365ProPlusRetail">
      <Language ID="en-us" />
    </Product>
  </Add>
  <!--  <Updates Enabled="TRUE" Channel="Monthly" /> -->
  <Display Level="None" AcceptEULA="TRUE" />
  <Logging Level="Standard" Path="." />
  <!--  <Property Name="AUTOACTIVATE" Value="1" />  -->
</Configuration>

test-o365.ps1

# Write current datetime into result.xlsx to verify that Office COM component is working.
$filename = [System.Environment]::CurrentDirectory + "\result.xlsx"
$filename
if ([System.IO.File]::Exists($filename )) {    
    Remove-Item $filename 
}
$xl=New-Object -ComObject Excel.Application
$xl.Visible=$false
$wb=$xl.WorkBooks.Add()
$ws=$wb.WorkSheets.item(1)
$ws.Cells.Item(1,1)= [System.DateTime]::Now
$wb.SaveAs($filename)
$xl.Quit()

More information

We are already aware of 'server-side Automation of Office' issues as mentioned in article [3]. At current stage, we are evaluating the possibility on running legacy ASP.NET application in Windows container, with Office/COM inter-operation enabled.

References

  1. Overview of the Office Deployment Tool
  2. What is the Server Core installation option in Windows Server?
  3. Considerations for server-side Automation of Office
Kai Wang
  • 53
  • 3

1 Answers1

2

I've been struggling with this for a while, and finally got it to work. I found the solution to the 17002 error was to run the setup.exe /configure config.xml while running the docker image interactively, and then committing that container. This worked for me on the windows:1809 image.

Full writeup

I'm copying the downloaded office files into the docker image separately, as I was having issues with getting the download to work from inside the docker file (see here). So I have the folder Office at the same level as the docker file with the contents of setup.exe /download config.xml. Then the docker file below builds a base image. I ran docker run -it {IMAGEID} powershell, navigate to C:\\odtsetup and with the interactive console run setup.exe /configure config.xml, exit the container and run

docker stop {CONTAINERID}
docker commit {CONTAINERID}` 

I now have a base windows server image with docker installed, and can use it in the dockerfile for my application. If I need to update the server image or excel version I'll need to do this manually again, but I'm just thankful it's working.

DOCKERFILE

FROM mcr.microsoft.com/windows:1809
WORKDIR C:\\odtsetup
ADD https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_13426-20308.exe odtsetup.exe
RUN odtsetup.exe /quiet /norestart /extract:C:\\odtsetup
ADD config.xml .
ADD Office Office\\

config.xml

<Configuration>
  <Add OfficeClientEdition="64" Channel="PerpetualVL2019">
    <Product ID="O365ProPlusRetail">
      <Language ID="MatchOS" />
      <ExcludeApp ID="Access" />
      <ExcludeApp ID="Groove" />
      <ExcludeApp ID="Lync" />
      <ExcludeApp ID="OneDrive" />
      <ExcludeApp ID="OneNote" />
      <ExcludeApp ID="Outlook" />
      <ExcludeApp ID="PowerPoint" />
      <ExcludeApp ID="Publisher" />
      <ExcludeApp ID="Teams" />
      <ExcludeApp ID="Word" />
    </Product>
  </Add>
  <Updates Enabled="FALSE" />
  <Display Level="None" AcceptEULA="TRUE" />
  <Property Name="AUTOACTIVATE" Value="1"/>
  <Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
  <Remove All="TRUE">
  </Remove>
</Configuration>
Nick Murphy
  • 129
  • 1
  • 6
  • 1
    Running it interactively also worked for me. But I only have this issue with the windows:1809 base image. With windows:1903 the install works fine during the docker build. For windows:2004, when I try to check if Word is working after a successful install with new-object -comobject word.application, I obtain "Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070520 A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520)." – mfbieber Mar 09 '21 at 22:29
  • 1
    Actually, I fear that I have to add something else: The installation in 1809 is not successful in the interactive mode, it simply does not throw a non-zero exit code. If you check the logs in the %temp% folder, you will see that it stops at 94% and exits with 17002. Everything in the C:\Program Files\Microsoft Office\Office16 folder is missing (and maybe more?) so e.g. an activation via KMS is not possible to do with the opps.vbs script, which is missing. I don't know what else is missing, Word, Excel and PowerPoint work to some extent. – mfbieber Mar 18 '21 at 15:38
  • @Nick, my container gets stuck at '/configure' step. its neither moving ahead nor exiting the interactive mode. – deathrace Nov 09 '21 at 11:55
  • @mfbieber were you able to resolve the 80070520 error? – karthikeayan May 23 '22 at 19:18
  • @Nick What is odtsetup.exe? is it the exe we get from the link? because when i use the exact same scripts you wrote, i am getting below error: `odtsetup.exe : The term 'odtsetup.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.` – shab Jul 27 '22 at 01:47