Executing exe in others' user context???
-
Hi, i want to execute a exe in other's context so i tried the following code HANDLE hUserToken; LogonUser(_T("username"),_T("domain"), _T("password"), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken); STARTUPINFO startupInfo; memset(&startupInfo, '\0', sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); startupInfo.dwFlags = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_SHOW; PROCESS_INFORMATION procInfo; memset(&procInfo, '\0', sizeof(procInfo)); BOOL b = CreateProcessAsUser(hUserToken, fileName.c_str(), NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &procInfo); DWORD dw = GetLastError(); } but i get the dw = 1314 saying "A required privilege is not held by the client." If i right click the exe and choose the run as option giving user name and password it works fine. but how to execute that through code? Where i am going wrong?
-
Hi, i want to execute a exe in other's context so i tried the following code HANDLE hUserToken; LogonUser(_T("username"),_T("domain"), _T("password"), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hUserToken); STARTUPINFO startupInfo; memset(&startupInfo, '\0', sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); startupInfo.dwFlags = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_SHOW; PROCESS_INFORMATION procInfo; memset(&procInfo, '\0', sizeof(procInfo)); BOOL b = CreateProcessAsUser(hUserToken, fileName.c_str(), NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &procInfo); DWORD dw = GetLastError(); } but i get the dw = 1314 saying "A required privilege is not held by the client." If i right click the exe and choose the run as option giving user name and password it works fine. but how to execute that through code? Where i am going wrong?
sandeepkavade wrote:
but how to execute that through code?