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 DOS command not working
Qt 6.11 is out! See what's new in the release blog

QProcess DOS command not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 501 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.
  • T Offline
    T Offline
    TGRSM
    wrote on last edited by
    #1

    I'm trying to invoke the Windows On-Screen Keyboard with the command:

    C:\Windows\System32\osk.exe

    Running this command from DOS works perfectly fine.

    But when I run from with the Qt application

    int exitCode = QProcess::execute( "c:/Windows/System32/osk.exe");

    The exit code is -2.

    I have also tried to wrap this within a DOS bat script and execute this as follows:

    int exitCode = QProcess::execute( "cmd /c \"w:/scripts/myscript.bat\"");

    And myscript.bat has:

    c:\Windows\System32\osk.exe

    But this gives:

    'c:\Windows\System32\osk.exe' is not recognized as an internal or external command, operable program or batch file.

    JonBJ JoeCFDJ 2 Replies Last reply
    0
    • T TGRSM

      I'm trying to invoke the Windows On-Screen Keyboard with the command:

      C:\Windows\System32\osk.exe

      Running this command from DOS works perfectly fine.

      But when I run from with the Qt application

      int exitCode = QProcess::execute( "c:/Windows/System32/osk.exe");

      The exit code is -2.

      I have also tried to wrap this within a DOS bat script and execute this as follows:

      int exitCode = QProcess::execute( "cmd /c \"w:/scripts/myscript.bat\"");

      And myscript.bat has:

      c:\Windows\System32\osk.exe

      But this gives:

      'c:\Windows\System32\osk.exe' is not recognized as an internal or external command, operable program or batch file.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @TGRSM
      This was asked a few weeks ago. Search the forum posts.

      The upshot is you're trying to run a 32-bit from a 64-bit environment, or vice versa.

      1 Reply Last reply
      1
      • T TGRSM

        I'm trying to invoke the Windows On-Screen Keyboard with the command:

        C:\Windows\System32\osk.exe

        Running this command from DOS works perfectly fine.

        But when I run from with the Qt application

        int exitCode = QProcess::execute( "c:/Windows/System32/osk.exe");

        The exit code is -2.

        I have also tried to wrap this within a DOS bat script and execute this as follows:

        int exitCode = QProcess::execute( "cmd /c \"w:/scripts/myscript.bat\"");

        And myscript.bat has:

        c:\Windows\System32\osk.exe

        But this gives:

        'c:\Windows\System32\osk.exe' is not recognized as an internal or external command, operable program or batch file.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @TGRSM
        Do not you need arguments to call execute?
        int QProcess::execute(const QString &program, const QStringList &arguments)
        https://doc.qt.io/qt-5.15/qprocess.html#execute

        The following one is run like
        QStringList arguments;
        arguments << "/c"
        << ""w:/scripts/myscript.bat""
        int exitCode = QProcess::execute( "cmd", arguments );

        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