Windows cmd.exe startDetached fails
Solved
General and Desktop
-
I recently updated from Qt 5.6 to Qt 5.10.1 and the function below now fails to work. Windows console is not opened when the function is called. I rechecked with a recompile using 5.6 and the function works fine. Why does this code work with 5.6 and previous releases and not with Qt 5.10.1?
void MainWindow::on_doConsole_clicked() { QString commstr = adbdir+"cpath.bat"; QFile file(commstr); if(!file.open(QFile::WriteOnly | QFile::Text)) { logfile("error creating cpath.bat!"); QMessageBox::critical(this,"","Error creating bat file!"); return; } QTextStream out(&file); out << "set PATH=%PATH%;"+QDir::currentPath()+";"<< endl; file.flush(); file.close(); cstring = "cmd /k " +QDir::currentPath()+"/cpath.bat"; QProcess::startDetached(cstring);
}
-
Hi,
Please read the part of the QProcess documentation about CreateProcessArgumentModifier.
It'll show you have to handle your use case.
-