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. How to start and pass Arguments to windows service.
Forum Updated to NodeBB v4.3 + New Features

How to start and pass Arguments to windows service.

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.5k 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.
  • S Offline
    S Offline
    Shankar B
    wrote on last edited by
    #1

    I have created my own windows service.
    How to start and pass arguments to created windows service through Qt application.

    JonBJ 1 Reply Last reply
    0
    • S Shankar B

      I have created my own windows service.
      How to start and pass arguments to created windows service through Qt application.

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

      @Shankar-B
      It seems Qt (beign aimed at platform-independence) does not come with in-built support for interacting with Windows services.

      I would refer you to https://stackoverflow.com/questions/46484616/how-to-start-stop-windows-service-using-qt (and https://github.com/qtproject/qt-solutions) as a possible starting point. Otherwise you could use QProcess to spawn net start/stop commands (ugly) or the Win API for native support (https://docs.microsoft.com/en-us/windows/win32/services/service-functions).

      HoMaH 1 Reply Last reply
      1
      • HoMaH Offline
        HoMaH Offline
        HoMa
        wrote on last edited by
        #3

        Using the search engine google I found
        https://github.com/qtproject/qt-solutions/blob/master/qtservice/examples/controller/main.cpp
        Which looks like a good implementation of a service control manager client

        1 Reply Last reply
        3
        • JonBJ JonB

          @Shankar-B
          It seems Qt (beign aimed at platform-independence) does not come with in-built support for interacting with Windows services.

          I would refer you to https://stackoverflow.com/questions/46484616/how-to-start-stop-windows-service-using-qt (and https://github.com/qtproject/qt-solutions) as a possible starting point. Otherwise you could use QProcess to spawn net start/stop commands (ugly) or the Win API for native support (https://docs.microsoft.com/en-us/windows/win32/services/service-functions).

          HoMaH Offline
          HoMaH Offline
          HoMa
          wrote on last edited by
          #4

          @JonB
          SC.EXE is an Even more powerful command line tool and with it one can also install services. You may want to read this on arguments:
          https://serverfault.com/questions/143367/how-to-start-a-service-with-certain-start-parameters-on-windows

          JonBJ 1 Reply Last reply
          0
          • HoMaH HoMa

            @JonB
            SC.EXE is an Even more powerful command line tool and with it one can also install services. You may want to read this on arguments:
            https://serverfault.com/questions/143367/how-to-start-a-service-with-certain-start-parameters-on-windows

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

            @HoMa
            I am aware of SC.EXE. Having written Windows services and applications which call them, I would always prefer to use an API from code over an OS command, be that SC or NET ....

            HoMaH 1 Reply Last reply
            0
            • JonBJ JonB

              @HoMa
              I am aware of SC.EXE. Having written Windows services and applications which call them, I would always prefer to use an API from code over an OS command, be that SC or NET ....

              HoMaH Offline
              HoMaH Offline
              HoMa
              wrote on last edited by
              #6

              @JonB No doubt! However, the API is not as trivial as starting a process. So if one is not so much interested in the details, the tools might be easier to use.

              JonBJ 1 Reply Last reply
              1
              • HoMaH HoMa

                @JonB No doubt! However, the API is not as trivial as starting a process. So if one is not so much interested in the details, the tools might be easier to use.

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

                @HoMa
                Fair enough. Then @Shankar-B should be aware that if using QProcess he really ought write all the usual code for checking return results and reading from stdout/err, as the OS command could easily fail and user will not be aware/know why.

                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