Search code examples
winapishellexecutemql5

ShellExecute hold screen after execution and wait for character


#import "shell32.dll" 

int ShellExecuteW(int hwnd,string operation,string file,string parameters,string directory,int showCmd); 

#import
string strParameters = "/c terms.exe";

    int result = ShellExecuteW(0, "open", "cmd.exe", strParameters , NULL, 1);

    if (result <= 32) Print("Shell Execute Failed: ", result);

The above is my code to execute external executable in MQL using the windows 10 ShellExecute command. But there is a problem in the program and that I see on the terminal but as the terminal is getting away without letting me read the error I cannot debug the issue. Kindly, let me know how I can hold the screen on till I press key. So that I could be able to read the message.

Please help me with this.


Solution

  • Change the "cmd.exe" parameters:

    string strParameters = "/k terms.exe";
    

    This keeps the console window open, after the command has been executed.