-3

I am using createProcess in C to open a command prompt to execute a jar . I have figured out all the kinks but for sake of debugging would like to somehow add something where the console just does not flash and is gone immediately.

What I am looking is for the jar to be executed and command window wait for a button press from me before it terminates.

This will only be for debugging and I will remove it before putting it out so as the console window does not hang and kill everything down the line.

    if (!CreateProcess(NULL,   // No module name (use command line)
        "java -jar testfile.jar",        // 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
        ){
            MessageBox(0, "test jar passed", "jar executed", 1);
            return 1;
        }
    else {
        printf("create process call to jar was sucessful");
        MessageBox(0,"jar failed", "Error Test", 1);
        return 0;
    }
}

I am not using it IDE but installing on a different system so I need to create dll. Cant use IDE feature's to stall command prompt there

Praveen
  • 101
  • 14

1 Answers1

1

To stop the blinking of console, you can use getch().

getch() waits for user to input character. If you don't have getch(), you can use other functions like getche(),getchar(). But unlike getch() it takes an extra newline.

I think it solves your problem.

SkrewEverything
  • 2,393
  • 1
  • 19
  • 50