Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved close/kill another Windows process which is started by run a .bat in Qt app

    General and Desktop
    3
    3
    236
    Loading More Posts
    • 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.
    • O
      opengpu last edited by

      any way to close/kill another Windows process which is started by run a .bat in Qt app?

      jsulm JonB 2 Replies Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @opengpu last edited by

        @opengpu I guess you're using QProcess (you did not say how you're starting the process).
        If so what about:

        • https://doc.qt.io/qt-5/qprocess.html#close
        • https://doc.qt.io/qt-5/qprocess.html#kill
        • https://doc.qt.io/qt-5/qprocess.html#terminate

        ?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 4
        • JonB
          JonB @opengpu last edited by JonB

          @opengpu
          Provided you mean the Windows process started from the BAT responds to the BAT being terminated then as @jsulm says you should be able to terminate it by terminating the QProcess used to launch the BAT. However, if the sub-process has "gone interactive" and the BAT file is not waiting for it (e.g. run notepad.exe or start from a BAT), you will have to find the sub-process and kill that (e.g. taskkill.exe, EnumProcesses).

          1 Reply Last reply Reply Quote 3
          • First post
            Last post