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. [solved] How to create a service with Qt and sc.exe under windows 7
Forum Updated to NodeBB v4.3 + New Features

[solved] How to create a service with Qt and sc.exe under windows 7

Scheduled Pinned Locked Moved General and Desktop
qprocesswindows servicewin32shellexecute
11 Posts 3 Posters 5.1k Views 2 Watching
  • 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
    stephane78
    wrote on last edited by
    #2

    the first line of code is

     QProcess pc;
    
    
    K 1 Reply Last reply
    0
    • S stephane78

      the first line of code is

       QProcess pc;
      
      
      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #3

      @stephane78
      It is more interesting what is happening after pc.start()
      Do you do a waitForFinished?
      Is there end of the method and your pc is deleted immediately?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • S Offline
        S Offline
        stephane78
        wrote on last edited by
        #4

        @koahnig
        Hi, no I don't do a waitForFinished and yes it is the end of the method so pc is deleted.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stephane78
          wrote on last edited by
          #5

          @koahnig

          you are right I will try with waitForFinished....

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stephane78
            wrote on last edited by
            #6

            @koahnig
            Hi, waitForFinished() returns true but the service isn't still added in the list of services.

            K 1 Reply Last reply
            0
            • S stephane78

              @koahnig
              Hi, waitForFinished() returns true but the service isn't still added in the list of services.

              K Offline
              K Offline
              koahnig
              wrote on last edited by
              #7

              @stephane78
              I do not have enough experience with services.

              I assume that you have checked the syntax of your command externally and it works fine from command line. Therefore, the only I can recommend is to start your application from outside of Qt creator environment. If you have checked this already and it does not work either, I am of no help here.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stephane78
                wrote on last edited by
                #8

                @koahnig
                HI, I change the code and used QProcess::execute and it didn't add the service and after that I have found a solution: if I execute my program "as administrator" in Windows then it add my service to the list of service and it is ok so perhaps there is another solution with win32 functions instead of QProcess that runs an external program as administrator....

                K 1 Reply Last reply
                0
                • S stephane78

                  @koahnig
                  HI, I change the code and used QProcess::execute and it didn't add the service and after that I have found a solution: if I execute my program "as administrator" in Windows then it add my service to the list of service and it is ok so perhaps there is another solution with win32 functions instead of QProcess that runs an external program as administrator....

                  K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #9

                  @stephane78
                  So it was basically a missing admin rights issue.
                  AFAIK there is no other way than QProcess. Also it would be quite dangerous to be able to plant some applications with admin rights from an application with no admin rights. Any decent virus scan prevent this anyhow.

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    stephane78
                    wrote on last edited by
                    #10

                    @koahnig
                    it is out of subject on this forum, but I tested with the win32 function Shellexecute and "runas" as second parameter instead of qprocess and it created my service.so I mark this subject solved.thanks.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Anjuchauhan
                      Banned
                      wrote on last edited by koahnig
                      #11
                      This post is deleted!
                      1 Reply Last reply
                      -2

                      • Login

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