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. Run as service
QtWS25 Last Chance

Run as service

Scheduled Pinned Locked Moved Solved General and Desktop
windowsservice
13 Posts 6 Posters 11.8k 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.
  • M Offline
    M Offline
    Max13
    wrote on 10 May 2016, 14:52 last edited by
    #1

    Hi there,
    I'm writing a simple "ping" app that sends a ping to out server periodically. The thing is my company wants it to start as a service, to be able to "see" a powered-on computer even if it has restarted and/or without anyone logged in.

    Is there a solution provided by Qt? I can't find something useful for me.

    Thank you for your help

    We all have started by asking questions. Then after some time, we can begin answering them.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 10 May 2016, 15:03 last edited by
      #2

      I can't find something useful for me.

      Perhaps, because you lazy looking for?
      QtService: https://github.com/qtproject/qt-solutions

      M 1 Reply Last reply 10 May 2016, 15:29
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 10 May 2016, 15:19 last edited by
        #3

        hi
        alternatively u could just cheat and use a tool to run it as service.
        http://www.howtogeek.com/50786/using-srvstart-to-run-any-application-as-a-windows-service/

        1 Reply Last reply
        1
        • K kuzulis
          10 May 2016, 15:03

          I can't find something useful for me.

          Perhaps, because you lazy looking for?
          QtService: https://github.com/qtproject/qt-solutions

          M Offline
          M Offline
          Max13
          wrote on 10 May 2016, 15:29 last edited by
          #4

          @kuzulis said:

          Perhaps, because you lazy looking for?

          I found this but while I'm struggling with an error on make g++: error: CreateProcess: No such file or directory, I still hoping there is something included in Qt. Maybe my error is related to the fact that I'm on 5.6 (and the project mentions 5.5), but that's another thread.

          @mrjj said:

          alternatively u could just cheat and use a tool to run it as service.

          I also thought about this at first (like the included sc, as command line), but as the app will run on around 30 computers and will be installed by users, I need a simple workflow. So either a simple command line tool that will be run on the first start by my app (after install) or the above solution provided by @kuzulis (or similar)

          We all have started by asking questions. Then after some time, we can begin answering them.

          K 1 Reply Last reply 10 May 2016, 20:21
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 10 May 2016, 15:36 last edited by
            #5

            @Max13 said:

            g++: error: CreateProcess:

            is that mingw compiler?

            Oh, i understand. To Make installer to setup the app as service is
            as much work as making native a service. :)

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on 10 May 2016, 16:56 last edited by
              #6

              Why don't you just run ping from a cron job?

              M 1 Reply Last reply 11 May 2016, 11:20
              0
              • M Max13
                10 May 2016, 15:29

                @kuzulis said:

                Perhaps, because you lazy looking for?

                I found this but while I'm struggling with an error on make g++: error: CreateProcess: No such file or directory, I still hoping there is something included in Qt. Maybe my error is related to the fact that I'm on 5.6 (and the project mentions 5.5), but that's another thread.

                @mrjj said:

                alternatively u could just cheat and use a tool to run it as service.

                I also thought about this at first (like the included sc, as command line), but as the app will run on around 30 computers and will be installed by users, I need a simple workflow. So either a simple command line tool that will be run on the first start by my app (after install) or the above solution provided by @kuzulis (or similar)

                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 10 May 2016, 20:21 last edited by
                #7

                @Max13
                What OS are we talking? I recently began (and implemented for Linux) such a thing (Qt 5.5 compatible). My idea is that at some point I wrap up the Windows code as well.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  the_
                  wrote on 11 May 2016, 05:51 last edited by
                  #8

                  I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

                  @Max13 said:

                  I also thought about this at first (like the included sc, as command line), but as the app will run on around 30 computers and will be installed by users, I need a simple workflow. So either a simple command line tool that will be run on the first start by my app (after install) or the above solution provided by @kuzulis (or similar)

                  As far as i remember you need full Admin rights (on Win7 it was not enough to run the CMD as administrator when logged in as a normal user) to register/install a service. I was looking for installer kits that can do that but could not find any examples for this.

                  -- No support in PM --

                  1 Reply Last reply
                  1
                  • ? A Former User
                    10 May 2016, 16:56

                    Why don't you just run ping from a cron job?

                    M Offline
                    M Offline
                    Max13
                    wrote on 11 May 2016, 11:20 last edited by
                    #9

                    @mrjj said:

                    is that mingw compiler?

                    Oh, i understand. To Make installer to setup the app as service is
                    as much work as making native a service. :)

                    It's mingw, installed with Qt. It's easier for the user (therefor for me, if I don't have to help them) if I make an installer that installs (as a service) and start. Then the user has NOTHING to do except double clicking the installer.

                    @Wieland said:

                    Why don't you just run ping from a cron job?

                    It's not just really a ping. Currently it's calling an API to say "I'm still awake", the plan is to "ping" with a some logs.

                    @kshegunov said:

                    What OS are we talking?

                    Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

                    @the_ said:

                    I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

                    I don't doubt it. I want to avoid native APIs as much as possible. To keep the cross-platform ability

                    Finally, I managed to compile QtSolutions/QtService using just the cmd command line by Qt. All the env variables was there. It's a little bit complicated to understand the first time how to implement it, as there is only examples, but I simply has to wrap my code in an overridden QtService::start() and that's it.

                    My project is Open Source: https://github.com/Max13/Pulse-Qt

                    Thank you for your help

                    We all have started by asking questions. Then after some time, we can begin answering them.

                    K 2 Replies Last reply 11 May 2016, 12:52
                    1
                    • M Max13
                      11 May 2016, 11:20

                      @mrjj said:

                      is that mingw compiler?

                      Oh, i understand. To Make installer to setup the app as service is
                      as much work as making native a service. :)

                      It's mingw, installed with Qt. It's easier for the user (therefor for me, if I don't have to help them) if I make an installer that installs (as a service) and start. Then the user has NOTHING to do except double clicking the installer.

                      @Wieland said:

                      Why don't you just run ping from a cron job?

                      It's not just really a ping. Currently it's calling an API to say "I'm still awake", the plan is to "ping" with a some logs.

                      @kshegunov said:

                      What OS are we talking?

                      Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

                      @the_ said:

                      I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

                      I don't doubt it. I want to avoid native APIs as much as possible. To keep the cross-platform ability

                      Finally, I managed to compile QtSolutions/QtService using just the cmd command line by Qt. All the env variables was there. It's a little bit complicated to understand the first time how to implement it, as there is only examples, but I simply has to wrap my code in an overridden QtService::start() and that's it.

                      My project is Open Source: https://github.com/Max13/Pulse-Qt

                      Thank you for your help

                      K Offline
                      K Offline
                      kshegunov
                      Moderators
                      wrote on 11 May 2016, 12:52 last edited by kshegunov
                      #10

                      @Max13 said:

                      Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

                      Currently only for Linux. I have some old source for windows that I'm going to refactor, but I've been busy ... you know how it is.

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      1
                      • M Max13
                        11 May 2016, 11:20

                        @mrjj said:

                        is that mingw compiler?

                        Oh, i understand. To Make installer to setup the app as service is
                        as much work as making native a service. :)

                        It's mingw, installed with Qt. It's easier for the user (therefor for me, if I don't have to help them) if I make an installer that installs (as a service) and start. Then the user has NOTHING to do except double clicking the installer.

                        @Wieland said:

                        Why don't you just run ping from a cron job?

                        It's not just really a ping. Currently it's calling an API to say "I'm still awake", the plan is to "ping" with a some logs.

                        @kshegunov said:

                        What OS are we talking?

                        Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

                        @the_ said:

                        I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

                        I don't doubt it. I want to avoid native APIs as much as possible. To keep the cross-platform ability

                        Finally, I managed to compile QtSolutions/QtService using just the cmd command line by Qt. All the env variables was there. It's a little bit complicated to understand the first time how to implement it, as there is only examples, but I simply has to wrap my code in an overridden QtService::start() and that's it.

                        My project is Open Source: https://github.com/Max13/Pulse-Qt

                        Thank you for your help

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 13 May 2016, 17:43 last edited by kshegunov
                        #11

                        @Max13
                        Hello,
                        Just letting you know that as of today I have an implementation for Windows as well. Still tweaking it a bit (the installation/ deinstallation should update the PATH), but it appears to be fully functional otherwise. Let me know if you're interested.

                        I just merged the win32 branch, so you can get the library here.

                        Kind regards.

                        Read and abide by the Qt Code of Conduct

                        M 1 Reply Last reply 18 May 2016, 21:55
                        2
                        • K kshegunov
                          13 May 2016, 17:43

                          @Max13
                          Hello,
                          Just letting you know that as of today I have an implementation for Windows as well. Still tweaking it a bit (the installation/ deinstallation should update the PATH), but it appears to be fully functional otherwise. Let me know if you're interested.

                          I just merged the win32 branch, so you can get the library here.

                          Kind regards.

                          M Offline
                          M Offline
                          Max13
                          wrote on 18 May 2016, 21:55 last edited by
                          #12

                          @kshegunov said:

                          Just letting you know that as of today I have an implementation for Windows as well.

                          I'm playing around with QtService, but I'll look at yours as soon as I can ;)

                          We all have started by asking questions. Then after some time, we can begin answering them.

                          K 1 Reply Last reply 18 May 2016, 23:36
                          0
                          • M Max13
                            18 May 2016, 21:55

                            @kshegunov said:

                            Just letting you know that as of today I have an implementation for Windows as well.

                            I'm playing around with QtService, but I'll look at yours as soon as I can ;)

                            K Offline
                            K Offline
                            kshegunov
                            Moderators
                            wrote on 18 May 2016, 23:36 last edited by
                            #13

                            @Max13
                            Do let me know whether it's convenient to use, and of course suggestions are welcome. (bug reports please post on the issue tracker).

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply
                            0

                            4/13

                            10 May 2016, 15:29

                            9 unread
                            • Login

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