Process::openDocument not working on Windows 10 LTCS

The juce::Process::openDocument does not properly work on Windows 10 LTCS.

My application uses the openDocument method to open some PDF files. It works just fine when using my application under Windows 7 and Windows 10 Pro. However, when using Windows 10 Enterprise LTCS (version 1809, OS build 17763.615) it fails. The program tries to launch Adobe Acrobat Reader DC (32 bit) twice as shown on the Task Manager (see attached image), but Adobe is never opened. After my application is closed, then the Task Manager also shows Adobe Acrobat Update Services (32 bit) is also running (see second attached image). Is this what is causing this problem?

I’m using the latest version of Adobe Acrobat Reader DC (version 19.012.20034).

Is there a bug with the openDocument method?
All the juce source code was generated using Introjucer version 3.2.0.

Any help is really appreciated!
Thanks,
Stalin

If you look at the code for Process::openDocument() here it just calls ShellExecute with the filename, I can’t see how this would be an issue on different versions of Windows. Perhaps try checking the return value of that method as the docs indicate that it’ll return an error code if it fails which might indicate what is going on.

The return value from ShellExecute is 42. According the the documentation, this is not an error code, but still fails to launch Adobe Reader. Any ideas what could be causing this problem?

What happens if you just double-click a .pdf file from the file explorer? That should be doing the same thing as the openDocument() method.

If I double-click a .pdf file from the file explorer, Adobe Reader is launched normally and the PDF contents are displayed. However, this is BEFORE executing my application. When trying to double-click the .pdf file from the file explorer AFTER executing my application, trying to open the PDF file (via ShellExecute), and then closing my application, Adobe doesn’t launch and just hangs as a background process (like shown on my second attachment). If the processes are terminated via the Task Manager (End task) then Adobe goes back to normal (i.e. double-clicking the .pdf file launches Adobe correctly).

BTW I’m also checking GetLastError after executing ShellExecute and it returns 0. So no errors there.

That’s odd, I’m not sure what could be going on. Are you passing any parameters to the openDocument() method? Can you also try modifying the arguments passed to ShellExecute() like so:

HINSTANCE hInstance = ShellExecute (0, "open", fileName.toWideCharPointer(),
                                    parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT);

Out of curiosity, are you building with the modules of juce 3.2.0?
Have you tried updating to a later version?

The method in question didn’t change since 3.2.0 though:

I don’t think, that the docs for ShellExecute now forward to ShellExecuteA means anything…

Thanks for all your help, I already solved this issue!
Apparently the problem was created because I’m running my application as Administrator and so Adobe Reader prevents launching due to its Protected Mode. For more information, I posted the actual problem and solution to Stack Overflow on this link:

Thanks again!

1 Like

I ran into the same problem.
I did not like the solution to ask users to deactivate the protected mode in Acrobat Reader.
Instead I found a solution, where you can run the shell execute as non-elevated, even if you application is running as elevated/administrator.

Here is the stack overflow link:

1 Like