|
Dear Community,
I'm using C++ to develop a small Bootstrapper (Setup.exe) application in C++. Using CreateProcess() to launch a .hta (HTML Application) which is used as a UI. It then calls other installers one by one which includes *.exe, *.msi etc.
What I'm trying to do is if I execute my Setup.exe, it asked for UAC for once and launch .hta so that it doesn't required UAC any further. Here is my code:
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( CreateProcess(NULL, "C:\\Windows\\MsHta.exe SetupGUI.hta" ,
NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
{
WaitForSingleObject(pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
I actually saw same in an application installer, but I don't have its Setup.exe's source code.
Thanks a lot.
Farrukh
|
|
|
|
|
I think it is nothing to do with how you call CreateProcess. If your main application Setup.exe is launched in elevated mode, all processes lunched by this application will be launched in elevated mode.
In order to have an elevated prompt for your Setup.exe, you need to create manifest.
This simple manifest will trigger the UAC prompt for your application:
="1.0"="UTF-8"="yes"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
<ms_asmv2:security>
<ms_asmv2:requestedPrivileges>
<ms_asmv2:requestedExecutionLevel level="requireAdministrator" uiAccess="false">
</ms_asmv2:requestedExecutionLevel>
</ms_asmv2:requestedPrivileges>
</ms_asmv2:security>
</ms_asmv2:trustInfo>
</assembly>
|
|
|
|