How to start a qprocess for opening files with a batch file?

  • Hi everyone!
    I am trying to open a qprocess that must open a .bat file that will compile another file. This is what I tried:
    QProcess p;
    p.start("C:/beez.bat", QStringList() << "E:/files/test.sma");

    I also tried this:

    QProcess::startDetached("C:/beez.bat E:/files/test.sma");

    When I execute this code, it just open the batch file without opening the .sma file (an extension I created). I can modify the sequence, I have to use the .bat file to opening it. Can you help me?

    Best Regards

  • What do you mean by, "it just open the batch file without opening the .sma file"? The program opens the BAT file in an editor, opens a black console window in which nothing happens, runs the BAT file but it malfunctions, something else?

    Possibly you need to start cmd.exe with appropriate arguments to run the BAT file:
    p.start("cmd.exe", QStringList() << "/C" << "C:\beez.bat" << "E:\files\test.sma");

  • Thanks for your answer as you sait the problem was arguments.
    The bat file I am using was used in console window so I made an editor in order to make it easier to use. When the user ends writing his code, he saves it (in a .sma file) and run it. So the BAT file, opens in a console window with the .sma file in argument and read it and display the result.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.