Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++: CreateProcess() launching child applications with UAC dialog for once

C++: CreateProcess() launching child applications with UAC dialog for once

Scheduled Pinned Locked Moved C / C++ / MFC
workspacec++htmldesignoop
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Farrukhw
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • F Farrukhw

      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

      C Offline
      C Offline
      chaau
      wrote on last edited by
      #2

      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 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups