0

I am trying to launch a setup.exe that is made through install-shield by using below code

DWORD ChildProcess(LPCSTR exePath, LPCSTR lpCmdLine ,BOOL showDialog, char* workingDir, BOOL bParentWait )
{
    CWnd * handle = AfxGetMainWnd (); //handle to the main dialog box of mfc application
    DWORD dwExitCode = -1;
    SHELLEXECUTEINFO ShExecInfo = {0};
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.lpVerb = "open";
    ShExecInfo.lpFile = exePath; //setup.exe path, installer exe

    if(bParentWait)
    {
        ShExecInfo.lpParameters =   lpCmdLine;
        ShExecInfo.nShow = SW_MINIMIZE;
    }
    else
    {
        ShExecInfo.nShow = SW_SHOW;
        ShExecInfo.lpParameters =   NULL;
    }
    ShExecInfo.lpDirectory = workingDir;

    ShExecInfo.hInstApp = NULL; 
    if (ShellExecuteEx(&ShExecInfo))
    {
        if(bParentWait)
        {

            handle->ShowWindow(SW_MINIMIZE);
            WaitForSingleObject(ShExecInfo.hProcess,INFINITE);  
            if(showDialog){
                handle->ShowWindow(SW_RESTORE);
            }
            GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);

        }
        else
        {
            CloseHandle(ShExecInfo.hProcess);
            dwExitCode = 0;
        }
    }

    return dwExitCode;
}

The problem is the launched installer window does not come on top. Any help would be greatly appreciated.

Thanks

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
ghani
  • 19
  • 2

1 Answers1

0

I believe the problem you have is because setup.exe spawns another process that executes the UI sequence(and thus shows the windows).

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176