C++: CreateProcess() launching child applications with UAC dialog for once
-
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, // No module name (use command line) "C:\\\\Windows\\\\MsHta.exe SetupGUI.hta" // Command line
,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure
))
{// Wait until child process exits. WaitForSingleObject(pi.hProcess, INFINITE ); // Close process and thread handles. 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
-
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, // No module name (use command line) "C:\\\\Windows\\\\MsHta.exe SetupGUI.hta" // Command line
,
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure
))
{// Wait until child process exits. WaitForSingleObject(pi.hProcess, INFINITE ); // Close process and thread handles. 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: