I have a simple program, just an empty GUI, that is launched from a SYSTEM service (mine) in the following way:
DWORD creationFlags = CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT | DETACHED_PROCESS | EXTENDED_STARTUPINFO_PRESENT;
auto returnCode = ::CreateProcessAsUser(
*m_userToken,
nullptr,
LPWSTR(commandLineUtf16),
nullptr,
nullptr,
FALSE, // lets not inherit any handles from the service!
creationFlags,
environmentBuffer,
LPWSTR(effectiveWorkingDirectory.utf16()),
reinterpret_cast<LPSTARTUPINFO>(&startupInfo),
&processInformation
);
If the program's manifest has a requestedExecutionLevel="asInvoker"
all is fine. It can be started from a admin and non admin user.
Otherwise, if not "asInvoker", CreateProcessAsUser(...)
returns FALSE and GetLastError()
is 0.
I'm totally stuck. If there's no error, why does it fail? If I run the program directly, it always works (admin, non admin, asInvoker, requireAdministrator...).
How can I find the reason of the fail?
Running on Windows 10 Enterprise Evaluation 64 bits VM, UAC full on