Solved

Windows Server 2008: Trouble running batch file as service

Posted on 2014-01-14
1
4,204 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
1 Comment
 
LVL 83

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

831 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