2

I've been spending a lot of time reading about the sc.exe to run an executable as a Windows Service and it seems it should be fairly straighforward bu I'm having some issues get it to work without this error: error 1053 the service did not respond or control request in a timely fashion.

I get the service to install and it is in the list of services but it is not allowing me to start it. This is what I'm using just a basic attempt:

>sc create TestService binPath= "C:\Program Files (x86)\[path.exe]" DisplayName= "TestingServices" start= auto

What am I doing wrong? Does my exe that I'm trying to run as a service have to be setup to properly be run as a service? I don't think that's the case because there are programs out there that can run any exe as a service. I'm trying to do the same, how can I do this?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
KJ3
  • 5,168
  • 4
  • 33
  • 53

4 Answers4

7

You can't just run any executable as a service; The executable needs to be written specifically to incorporate a service loop. The service loop recieves control requests (eg. start, stop, restart, suspend) and must perform processing such as initialisation for start, cleanup for stop, etc and respond to those control requests, otherwise the service control manager will kill it.

autistic
  • 1
  • 3
  • 35
  • 80
  • There's no way to make an exe that's not designed to be a service run as a service in the background? I know it's possible because there are programs out there that do it, but I imagine it's a little more complicated that just running it like I was trying to do. Is there a simple way to run an exe that's not designed to be a service as a service (just something to keep it always running). – KJ3 Feb 28 '13 at 04:53
  • 2
    *Running as a service* implies that it's designed to respond to service control requests. Have you ever seen an exe that's not designed to respond to service control requests, that's designed to respond to service control requests? Think carefully about your question. Don't ask X because X seems to be the way to do Y. Ask Y... Presuming you have the source code for this, implementing a service main isn't difficult. Have you tried? – autistic Feb 28 '13 at 05:01
1

Try to use

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe Assembly.exe|dll

instead.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
0

I have the same problem 3 months ago.. I've just check this sample. Then do the same syntax as you did. Then voila! It went good!

Freddie Fabregas
  • 1,162
  • 1
  • 7
  • 17
0

@UndefinedBehaviour is correct, there are some work arounds though

  • SrvAny.exe - from WinNT Resource Kit, looking fairly long in the tooth now
  • firedaemon - third party commercial product
fiat
  • 15,501
  • 9
  • 81
  • 103