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. Create process

Create process

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 Posts 3 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.
  • D Offline
    D Offline
    deeps_cute
    wrote on last edited by
    #1

    i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely

    Arise Awake Stop Not Till ur Goal is Reached.

    K D 3 Replies Last reply
    0
    • D deeps_cute

      i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely

      Arise Awake Stop Not Till ur Goal is Reached.

      K Offline
      K Offline
      kanduripavan
      wrote on last edited by
      #2

      Create a Hint (That can be a simple file or an registry end) at the end of the execution of the batch file or the exe (if src is available). CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); //check for the hint here //if (completed) call ur message //this is the raw way of doing it. MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION);

      D 1 Reply Last reply
      0
      • K kanduripavan

        Create a Hint (That can be a simple file or an registry end) at the end of the execution of the batch file or the exe (if src is available). CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); //check for the hint here //if (completed) call ur message //this is the raw way of doing it. MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION);

        D Offline
        D Offline
        deeps_cute
        wrote on last edited by
        #3

        i dont know how to confirm that the process is completed since the process is to install a package

        Arise Awake Stop Not Till ur Goal is Reached.

        1 Reply Last reply
        0
        • D deeps_cute

          i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely

          Arise Awake Stop Not Till ur Goal is Reached.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          deeps_cute wrote:

          i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened.

          It sounds like the problem is the other exe is not waiting on the batch file? So if your program is waiting on the exe (which is not waiting on the batch file), your program is also not waiting on the batch file? Can you confirm this (e.g., run calc.exe and see if your program waits for it)?

          deeps_cute wrote:

          startup.hStdInput=NULL;

          Since you've already called ZeroMemory(), this statement is pointless.

          deeps_cute wrote:

          CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1)...

          Why are you calling GetBuffer()? It is not necessary.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • D deeps_cute

            i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely

            Arise Awake Stop Not Till ur Goal is Reached.

            K Offline
            K Offline
            kanduripavan
            wrote on last edited by
            #5

            PROCESS_INFORMATION prcInfo; STARTUPINFO startupInfo; memset(&prcInfo, 0, sizeof(PROCESS_INFORMATION) ); memset(&startupInfo, 0, sizeof(STARTUPINFO ) ); startupInfo.cb = sizeof (STARTUPINFO ); //DEBUG_ONLY_THIS_PROCESS BOOL blnStatus = CreateProcess("e:\\temp\\samp.bat", NULL, //CreateProcess("c:\\winnt\\system32\\calc.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &prcInfo); if (blnStatus ) { STILL_ACTIVE DWORD dwExitCode=0; BOOL blnExit = GetExitCodeProcess(prcInfo.hProcess, &dwExitCode); WaitForSingleObject(prcInfo.hProcess, INFINITE); blnExit = GetExitCodeProcess(prcInfo.hProcess, &dwExitCode); dwExitCode=0; AfxMessageBox("Hello Fin",MB_OK); CloseHandle(prcInfo.hProcess); //This is the code that i had tested working fine for me. // i tested in both the case in which the first one i called //the executable file directly, in the second time i called //using a batch file. The next statement of WaitForSingleObject is watiting actuall to end its process.

            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