I've created the service using

sc create myService binpath=myservice.bat

But when I start it, it fails with the following error message:

[SC] StartService FAILED 1053:
    The service did not respond to the start or control request in a timely fashion.

On Win2k3 I used the srvany.exe from the Resource kit, but there's no resource kit for win2k8. For the time being I've installed the srvany.exe on my machine, but I don't think that's the best way to do it.


  • 1
    You can run a batch file as a service? Wouldn't a scheduled task be better? I know if you use an actual Windows Service, the OnLoad event needs to return within a few seconds.
    – tsilb
    Aug 16, 2009 at 8:29

10 Answers 10


Of course you can't run a service like that. Did you try using srvany in server 2008? As far as I know there is no 'official' version of srvany for s2k8, but you can always try, can you not?

EDIT: Oh, I forgot! We also use FireDaemon to run non-service applications as services. Though, it is not free and its functionality is a bit too much for your needs.

  • Which is what I wrote I did.
    – abyx
    Aug 16, 2009 at 7:51
  • hmm.. this is weird. It just filtered right through my brain. Sorry. Either way, srvany seems like the best thing to do in this situation.
    – shylent
    Aug 16, 2009 at 8:21
  • srvany works in 2008 (I use it to install and run Winamp.exe as a service on a home server)... but you can't run just a bat file. Aug 17, 2009 at 7:33

Use NSSM to run a .BAT or any old .EXE file as a service. It is almost a replacement for SRVANY and is a no frill no fuss application.


I had the same problem as you, and NSSM was the only utility that worked.

  • 3
    I hadn't heard of this before, but it appears to be a valuable tool. Thanks for the tip.
    – Skyhawk
    Aug 24, 2010 at 22:13
  • Thank you it worked for me. Though I am still looking for options to stop the service at a specified time.
    – Ankit
    Feb 3, 2015 at 12:32
  • Can you provide some code?
    – Demodave
    Jan 10, 2020 at 22:14

We use Task Scheduler to run task whenever the computer starts (regardless a user is logged in or not)

  • 1
    to hide the window read this or this if you aren't happy running as system
    – JonnyRaa
    Feb 23, 2015 at 9:38

You can't just run a .BAT file or any old .EXE file as a service. Windows services don't work that you. You can use a utility like the non-Sucking Service Manager (NSSM) or Microsoft's non-free SRVANY utility to run an arbitrary program as a service, but you may find that you don't get very "graceful" stopping behavior.


The SC command just adds the required registry entries for a service - if the file you specify isn't a valid service exe it won't turn it into one.


from: this post on technet forums: http://social.technet.microsoft.com/Forums/en-US/winserverMigration/thread/98a97aee-c62b-4683-94ab-3777899cf7de/

Here's what to do ...

At the time of this posting, there is no Windows Server 2008 Resource Kit Tools, so get the "srvany.exe " from the "Windows Server 2003 Resource Kit Tools " and copy it to a suitable location on your Win2008 server (e.g. C:\Windows\System32\ ). Use "sc " to create a new service that launches "srvany " (e.g. sc create MyService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service" ) Using RegEdit : create a "Parameters " key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Paramaters\ ) Using RegEdit : within the newly created "Parameters " key , create a string value called "Application " and enter the full path to the application you are wanting to run as a service. (No quotes required.)

And that should do it.

Note : some applications store their settings in a user hive, not under HKEY_LOCAL_MACHINE, so you will need to run the application to configure it, and then configure the service to run as that user.


try this... it worked for me..

sc create ServiceTest binpath= "C:\Windows\System32\cmd.exe /C C:\ServiceTest\Jenkins-Slave.bat"
  • 2
    It did not work for me as well! Same error as OP - Did not start in timely fashion. Jan 17, 2015 at 20:38
  • 1
    Ditto - did not work.
    – Spedge
    Jun 1, 2015 at 15:12

I stumbled upon this thing. Here is the tool called Bat_To_Exe_Converter. It's very very easy to convert any .bat files to .exe files. Try it. Download downloader first and it will download the Bat_To_Exe_Converter automatically then. It really helped me to create service which runs my .bat file through .exe. http://download.cnet.com/Bat-To-Exe-Converter/3001-2069_4-10555897.html?spi=eae5ab48292cc101b5f0ec370cf99ad0

  • Welcome to Server Fault! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Scott Pack
    Jul 8, 2013 at 17:40

i used Windows schtasks.

you can refer to this. https://technet.microsoft.com/en-us/library/cc725744.aspx#BKMK_hours


I found two other options that won't have you reaching for your wallet.

You can have sc launch srvany which then points to your program. (there's a forum post that I can't link to because I don't have enough rep here though I do on StackOverflow - grumble)

Here are the steps that the original poster used:

  1. Use sc to create a new service that launches srvany (e.g. sc create MyService binPath=C:\Windows\System32\srvany.exe DisplayName="My Custom Service")
  2. Using RegEdit: create a Parameters key for your service (e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\Parameters\)
  3. Using RegEdit: within the newly created Parameters key, create a string value called Application and enter the full path to the application you are wanting to run as a service. (No quotes required.)

If that seems like a bit of a hack, then you can build a .NET service to launch your process. If you want to skip a few steps, here's an open source .NET service that can launch generic processes:


Tweak it to your needs but it'll do most of what you want out of the box.

  • And is the srvany that you mention, the one from Win2k3 that has no supported version for Win2k8?
    – LarsH
    Oct 27, 2011 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.