QProcess is not working in WinXP , but it is working in all other machine...



  • I have used WMIC commad's in QProcess to fetch System Manufacturer and System Model name. Its working absolutely fine in Win Vista, Win 7 .But its not returning any value in Win XP ,

    @

    void CTestDlg::on_btnOk_clicked()
    {
    QStringList listResults = getProcResult("WMIC Path Win32_COMPUTERSYSTEM get Manufacturer,Model /FORMAT:list");
    QString strData;

    foreach( QString str , listResults)
        strData += str;
    
    ui->textEdit->setText( strData);
    

    }

    QStringList CTestDlg::getProcResult(QString strCmd )
    {
    QProcess *process = new QProcess();
    process->start( strCmd );
    process.waitForFinished( 10000 );

    //connect(process, SIGNAL(finished(int)), this, SLOT(commandFinished()));
     // Even i tried with SIGNAL(Finished) ..but no difference.
    
        QString sResult = QString( process.readAllStandardOutput() ).trimmed();
        if ( !sResult.isEmpty() )
            return sResult.split("\n");
    
    return QStringList();
    

    }

    @

    Please let me know whether i am doing anything wrong on this.



  • Check the exit and return codes of [[Doc:QProcess]].



  • Even i tried with all exitstatus, but no luck.

    Finally i have used a batch file with WMIC command inside the batch file. now its working fine.
    @
    QProcess *process = new QProcess();
    process->start( "executer.bat" ); // which contains WMIC Path Win32_COMPUTERSYSTEM get Manufacturer,Model /FORMAT:list

    process->closeWriteChannel();
    
    if( process->waitForFinished() )
    {
        qDebug() << "Succeed: ";
        QString sResult = QString( process->readAllStandardOutput() ).trimmed();
    
        process->close();
    
        if( !sResult.isEmpty() )
            return sResult.split("\n");
    }
    else
    {
        qDebug() << "Failed: " << process->errorString();
        process->close();
    
        return QStringList();
    }
    

    @


Log in to reply
 

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