Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess is not working in WinXP , but it is working in all other machine...
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

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

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        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();
        }
        

        @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved