My C++ application uses ShellExecute
to open a PDF file. I'm using Windows 10 Enterprise LTSC (version 1809, OS build 17763.615) to run my application. If my application is launched as Admin (right-click Run as administrator
) then it fails to open the PDF file. However, if my application is launched without Admin rights (just double-clicking it) then Adobe (the default PDF reader) is launched successfully and the PDF is displayed correctly.
My application runs normally (with and without Run as admin
) on Windows 7 and Windows 10 Pro. This issue just started happening now that we are trying to use Windows 10 Enterprise LTSC.
The actual code from my application is:
ShellExecute(NULL, NULL, full_path.toWideCharPointer(), NULL, NULL, SW_SHOWDEFAULT);
where full_path
is for example equal to "C:\\Faxitron\\Docs\\Guide.pdf"
.
In both cases (admin or not), ShellExecute
always returns 42 and GetLastError
returns 0. Here is something interesting: when running my application as Admin, the Task Manager shows 2 processes of Adobe Acrobat Reader DC (32 bit)
under my application, but the program Adobe is never launched/opened.
Not sure if this is relevant or not, but I'm using the latest version of Adobe Acrobat Reader DC (version 19.012.20034).
Finally, my application requires to be run as Admin (for other functionality to work properly). Is there a way to get ShellExecute
to work when running application as administrator?
The reason why ShellExecute
cannot launch the PDF viewer from an elevated process, in this case, is because Adobe Reader is preventing it via its Protected Mode. To solve this issue disable protected mode by doing the following:
For more information about Protected Mode (and possible vulnerabilities) refer to this link from Adobe.com: https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html