Solved

Windows Server 2008: Trouble running batch file as service

Posted on 2014-01-14
1
4,292 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 84

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

749 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