I am developing C++ service which uses CreateProcessAsUser function. I have tested this on Windows 7 and it was working excellent. But i am testing now my code for windows 10 and it doesnt want to work but process is created and visible in task manager, just no windows/console created. I am trying now code snippet with cmd only without any parameters I will really appreciate any kind of help
I can see this with task manager, so my process is created. task manager
PROCESS_INFORMATION pi;
STARTUPINFO si;
BOOL bResult = FALSE;
DWORD dwSessionId;
HANDLE hUserToken;
// Log the client on to the local computer.
dwSessionId = WTSGetActiveConsoleSessionId();
WTSQueryUserToken(dwSessionId,&hUserToken);
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb= sizeof(STARTUPINFO);
si.lpDesktop = L"winsta0\\default";
ZeroMemory(&pi, sizeof(pi));
LPVOID pEnv =NULL;
if(CreateEnvironmentBlock(&pEnv,hUserToken,TRUE)){
}
else
pEnv=NULL;
bResult = CreateProcessAsUser(
hUserToken, // client's access token
L"C:\\Windows\\System32\\cmd.exe", // file to execute
L"", // command line
NULL, // pointer to process SECURITY_ATTRIBUTES
NULL, // pointer to thread SECURITY_ATTRIBUTES
FALSE, // handles are not inheritable
CREATE_UNICODE_ENVIRONMENT|HIGH_PRIORITY_CLASS, // creation flags
pEnv, // pointer to new environment block
NULL, // name of current directory
&si, // pointer to STARTUPINFO structure
&pi // receives information about new process
);
//Perform All the Close Handles tasks
DestroyEnvironmentBlock(pEnv);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(hUserToken);