P
patanish
Hi,
I am trying to use CreateProcessAsUser() or CreateProcessWithLogonW().
The main application is running under a user login(non admin) and it
needs to start another process(a tool) that needs admin rights. If I
use the "runas" command form the command line to start the tool, it
works fine. But if I use the CreateProcessWithLogonW from my
application, it fails and I get error 1326 -
Logon failure: unknown user name or bad password. ERROR_LOGON_FAILURE
Here is the code snippet - Am I missing something??
Thanks in advance.
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
// Set up members of STARTUPINFO structure.
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
siStartInfo.cb = sizeof(STARTUPINFO);
HRESULT hRes = CreateProcessWithLogonW(_T("user-admin"),
_T("."),
_T("adminPwd"),
LOGON_WITH_PROFILE,
NULL,
cmdline, // application name
NULL, // creation flags
NULL, // use parent's environment
_T("C:\\"), // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION
I am trying to use CreateProcessAsUser() or CreateProcessWithLogonW().
The main application is running under a user login(non admin) and it
needs to start another process(a tool) that needs admin rights. If I
use the "runas" command form the command line to start the tool, it
works fine. But if I use the CreateProcessWithLogonW from my
application, it fails and I get error 1326 -
Logon failure: unknown user name or bad password. ERROR_LOGON_FAILURE
Here is the code snippet - Am I missing something??
Thanks in advance.
PROCESS_INFORMATION piProcInfo;
STARTUPINFO siStartInfo;
// Set up members of STARTUPINFO structure.
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
siStartInfo.cb = sizeof(STARTUPINFO);
HRESULT hRes = CreateProcessWithLogonW(_T("user-admin"),
_T("."),
_T("adminPwd"),
LOGON_WITH_PROFILE,
NULL,
cmdline, // application name
NULL, // creation flags
NULL, // use parent's environment
_T("C:\\"), // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION