Our normal workflow is to use a Windows Scheduled Task to:
- convert files from rtf to pdf in bulk
- manipulate the pdfs to add barcodes
- aggregate into a single pdf
- then send for printing
This was working fine on Windows Server 2008, but since our upgrade to Windows Server 2019 (end of life and whatnot) we've run into a whole host of issues. We're now falling down at the first hurdle- even instantiating the Word OLE client. The error isn't consistent - one day the process will complete successfully, the next it will fail immediately.
Our tasks trigger a Dyalog APL workspace, where the code to be executed sits. For debugging purposes, I have set up a simplified version which is doing the following:
tries←0 ⍝ Initialise the try counter
Log'Attempting to create Word instance' ⍝
:Repeat ⍝ Keep trying to...
Word←⎕NEW'OleClient'(⊂'ClassName' 'Word.Application') ⍝ Create the Word Client instance
Word.Visible←1 ⍝ making the application visible
tries+←1 ⍝ and incrementing the try counter each time
Log'Try: ',⍕tries ⍝
:Until #.Word.PropList∊⍨⊂'Documents' ⍝ Until it has seemingly created successfully
:OrIf tries≥maxTries_create ⍝ ... or the tries have exceeded the maximum (currently 5)
⍝
'doc open'delayAndLog dl_open ⍝ With an optional external delay...
myWordDoc←Word.Documents.Open⊂docPath ⍝ open the specified test doc
⍝
'doc close'delayAndLog dl_close ⍝ With an optional external delay...
myWordDoc.Close 0 ⍝ close the doc (not saving)
⍝
'application quit'delayAndLog dl_quit ⍝ With an optional external delay...
Word.Application.Quit 0 ⍝ quit the word client
The various delays are held externally in a config file. I didn't include the reading of this config file, as essentially what is shown here is the substance. Note: I retry creating the instance as sometimes I've found that it only instantiates with the barebones methods. Putting a delay in, or retries seemed to fix this.
This piece of code, will run completely fine in my non-prod servers (and even sometimes in production). Today, it will run fine when I am running it through the IDE, but when running as a Windows Scheduled Task it will report a DOMAIN ERROR when opening the document.
My observations are that it briefly creates the WINWORD.exe, i.e. you can see it in the task manager, the status turns to "suspended", then it disappears. In the event viewer, we see the following:
Event Viewer - ntdll application fault (id: 1000)
Things I've tried so far
- Rebooted the server (yes, you joke, but turning it off and on again is the first thing we should always try)
- Repaired Office
- Reinstalled Office
- Tried configuring the task to run as a different user (myself, with local admin rights)
- Tried configuring the task to run on a different server.
- Tried configuring the task to run with a higher priority.
- Making the Word instance visible, to see if there are any error pop-ups.
- Built a simplified version of the task (see above) to ensure it's not just the overall complexity of the main task causing confusion.
- Disabled "automatic inking" on Microsoft's recommendation
- Captured procmon logs of the error (awaiting Microsoft's review)
Versions currently installed:
- Word: Microsoft Word 2019 MSO (16.0.10374.20040) 64-bit
- Dyalog APL: 16.0.35960.0 32-bit Unicode
- Windows Server 2019 Standard Version 1809. OS Build 17763.1697.
Any help would be really greatly appreciated on this one as I feel like I'm tackling Schrödinger's OLE Client. Thanks in advance.