Executing BAT file using Qprocess



  • when my bat files are located in C folder program working fine but when i moved bat file from windows C to E Qt fails to call bat file.
    This is my program
    QProcess process;
    process.setProgram( "cmd.exe" );
    process.setArguments( { "/C", R"(E:\Run.bat)" } );
    process.setWorkingDirectory( R"(E:\ )" );
    process.setStandardOutputFile( QProcess::nullDevice() );
    process.setStandardErrorFile( QProcess::nullDevice() );
    process.startDetached();
    Please help to resolve..


  • Lifetime Qt Champion

    Hi
    You should check if it gives error

    connect(&process, &QProcess::errorOccurred, [=](QProcess::ProcessError error) 
    { 
        qDebug() << "error enum val = " << error; 
    });
    


  • Sorry, issue has been resolved it just beacause path of file within bat file was wrong..Thank you @mrjj


Log in to reply
 

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