Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Using wmic to get info
QtWS25 Last Chance

Using wmic to get info

Scheduled Pinned Locked Moved C++ Gurus
11 Posts 4 Posters 5.2k Views
  • 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.
  • U Offline
    U Offline
    user55
    wrote on 24 Sept 2014, 17:18 last edited by
    #1

    I'm making a QT application to retrieve info from OS.I'm trying to access wmic.exe directly ( i added the path Windows\System32\wbem\ previously in the code ) and i don't want to use it through cmd.The code works fine in Windows Vista/7 but doesnt work in Windows XP

    Sample code :

    @ QProcess process;
    process.start(QString("wmic bios get serialnumber"));
    process.waitForStarted();
    process.waitForFinished();
    qDebug()<<process.readAll();
    system("pause");@

    Note : I'm using QT 4.6

    Any Ideas ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Sept 2014, 20:34 last edited by
      #2

      Hi and welcome to devnet,

      Are you sure the command is available on XP and at the same place ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        user55
        wrote on 24 Sept 2014, 20:46 last edited by
        #3

        yes im pretty sure 100% u can even launch it from there and type the command and will work fine.I've been searching for a solution for days and no one is solving it.I'd appreciate it alott if u figure it out

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on 24 Sept 2014, 21:30 last edited by
          #4

          Are there any messages error, etc printed out ?
          What if you remove system("pause"); line ?

          1 Reply Last reply
          0
          • U Offline
            U Offline
            user55
            wrote on 25 Sept 2014, 02:55 last edited by
            #5

            No error messages are printed out . In win xp it just shows the console dash like forever no results are shown and program never ends while in win vista/7 normal results are shown.

            I tried removing system("pause") same issue.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 25 Sept 2014, 14:57 last edited by
              #6

              Did you read the standard out/error channels of QProcess ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • U Offline
                U Offline
                user55
                wrote on 25 Sept 2014, 18:38 last edited by
                #7

                There is literally 0 errors , that's why it's making me crazy

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 25 Sept 2014, 19:07 last edited by
                  #8

                  Did you check whether waitForStarted and waitForFinished returns true ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • U Offline
                    U Offline
                    user55
                    wrote on 25 Sept 2014, 19:11 last edited by
                    #9

                    yes so if i set a short time for waitforfinished lets say 2 sec , it will return empty result and program successfully ends

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 25 Sept 2014, 20:23 last edited by
                      #10

                      What's the exit code ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Fanaz
                        wrote on 2 Oct 2014, 08:26 last edited by
                        #11

                        Solved same problem a year ago.
                        This is part of working function from my app:

                        @...
                        QString Arguments = "/node:" + IP + " " + Args + " get /format:list";
                        ...
                        Process.setProcessChannelMode (QProcess::MergedChannels);
                        Process.start ("wmic");
                        Process.waitForStarted ();
                        Process.write (Arguments.toUtf8 ());
                        Process.closeWriteChannel();

                        while (Process.waitForReadyRead ())
                        {
                        while (Process.canReadLine())
                        {
                        ...@

                        1 Reply Last reply
                        1

                        1/11

                        24 Sept 2014, 17:18

                        • Login

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