Solved

Windows Server 2008: Trouble running batch file as service

Posted on 2014-01-14
1
4,375 Views
Last Modified: 2014-01-14
I need to run "C:\bat\runme.bat" in the background.  It is NOT

I tried this:
sc create customws binPath= "C:\custom\runme.bat" type= own

Open in new window


That successfully adds it to the list of webservices but when I click: "Start" I get an error:

Windows could not start the customws service on local computer.

Error 1053: The service did not respond to the start or control request in a timely fashion
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 39779471
sc.exe only creates the entry for the Service Manager, nothing more. It does not do any magical transformation of a batch file into a Windows service.
To run a program (in this case cmd.exe running a batch file) as a service that was not developed as a service, you need a wrapper that presents itself as a service and runs the program.
For W2k3, there was SrvAny.exe in the Resource Kit (http://www.microsoft.com/en-us/download/details.aspx?id=17657); it should still work on W2k8 (though only in 32bit) but the better solution is the "Non-Sucking Service Manager" from http://nssm.cc/
Download it and follow the instructions to let your batch file run as a service.
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Configuring Remote Assistance for use with SCCM
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question