This is what I wanted to do.
I have a script that currently just starts prints a message. Waits 5 seconds and prints another message before finishing by asking the user to press any key to end.
And I have a Qt application that needs to call this script and then quit.
I want the console window to open up to display and the script text and this new process to be able to continue after the Qt application has finished.
In windows my script is called "update.bat"
So I have tried:
QProcess::startDetached("update.bat");
QCoreApplication::quit();
but the console (windows one) does NOT open up (all output is in QtCreator) and it definitely does not continue after the application is finished.
Is there a way to do this using Qt?
I don't want to rely on the CreateProcess from windows, if possible, and use Qt solution.
EDIT:
I have alose tried the setCreateProcessArgumentModifier and to start the update.bat script with cmd /k. The results for all of this is exactly the same. Output is redirected to the QtCreator console and when executing the application outside of Qt nothing happens (this is all happens when you press a button).
QProcess p;
// QProcess process;
// process.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
// {
// args->flags |= CREATE_NEW_CONSOLE;
// args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
// args->startupInfo->dwFlags |= STARTF_USEFILLATTRIBUTE;
// args->startupInfo->dwFillAttribute = BACKGROUND_BLUE | FOREGROUND_RED
// | FOREGROUND_INTENSITY;
// });
p.startDetached("cmd.exe",QStringList() << "/k" << "update.bat");