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?
open
command, have you tried ? I know that windows fallback on many object when you are usingNULL
parameters, but it could worth it to provide them yourself. – VuwoxAcroRd32.exe
(which is apparently the Adobe command) with the PDF as arguments and that didn't work. Usingopen
didn't work either. – W. Stalin R.