Vote count:
0
I have developed an update service for my main application in Qt. Update service(Actually a windows service) runs under Local System privilege. Once update service receives update patch(prepared by Inno Setup) from server, it starts the patch executable and patch performs two tasks:
Here is a picture how all applications are started:
Patch executable inherits Local System privilege from Update Service and launcher inherits the same privilege from the patch executable. And Hence my main application is launched under Local System. But I want to launch my main application with the user privilege who is currently logged into Windows.
Here are few more things about the main application:
Here is the code of launcher written in VC++. It tries to launch the calc.exe under user account who is currently logged into Windows System. But it fails, my main application is being launched under Local System. I am a Qt and Java developer by profession. So basically I have no idea of Windows development stuff. Please give me a pointer to correct the code or provide me any other idea by which I can achieve my task.
HANDLE accountToken = (HANDLE)WindowsIdentity::GetCurrent()->Token;
TCHAR cmd[512] = TEXT("calc.exe");
STARTUPINFO startup_info;
PROCESS_INFORMATION process_information;
LPVOID pEnvironment;
HANDLE hTokenDup = NULL;
ZeroMemory(&startup_info, sizeof(startup_info));
startup_info.cb = sizeof(startup_info);
ZeroMemory(&process_information, sizeof(process_information));
ZeroMemory(&pEnvironment, sizeof(pEnvironment));
CreateProcessAsUser(accountToken, NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, &pEnvironment, NULL, &startup_info, &process_information);
Starting an application with the user privilege who is currently logged into Windows.
Aucun commentaire:
Enregistrer un commentaire