I want to make an installer that has the admin password embedded into it, so that I can let a simple user install a package.
I know that this is not good security practice and all, but that's what I am forced (by my employers) to do.
Now, I have written all the code and I am testing it in a Win7 virtual machine.
It works running it as an admin, but not when running it as simple user (which is what I want).
This is my code:
PROCESS_INFORMATION pInfo;
STARTUPINFOW sInfo = { 0 };
sInfo.cb = sizeof(STARTUPINFOW);
sInfo.lpReserved = NULL;
sInfo.lpReserved2 = NULL;
sInfo.cbReserved2 = 0;
sInfo.dwX = 0;
sInfo.dwY = 0;
sInfo.lpDesktop = NULL;
sInfo.lpTitle = NULL;
sInfo.dwFlags = STARTF_USESHOWWINDOW;
sInfo.dwFillAttribute = 0;
sInfo.wShowWindow = SW_HIDE;
CString cmdLine(_T("elevPrivInstaller.exe /q /norestart"));
BOOL ret = ::CreateProcessWithLogonW(_T("IEUser"), NULL, _T("Passw0rd!"), 0, NULL, (LPWSTR)(LPCTSTR)cmdLine, 0, NULL, NULL, &sInfo, &pInfo);
CreateProcessWithLogonW()
returns zero (which is failure).
GetLastError()
returns: Access is denied.
Does anyone have any idea why?
As far as I see, the credentials are correct.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…