Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a file "init.cmd" which has the following commands inside it:

set APP_ROOT=c:/wamp/www/myproj
ringo -b %APP_ROOT%/bin/init.js %APP_ROOT%/app/main.js

The file works fine when run from the command line, but I'd like to turn it into a Windows Service.

So I type:

sc create MyServiceName binPath= c:/wamp/www/myproj/bin/init.cmd

The service is created, but everytime I try to start it, it crashes saying:

Error 1053: The service did not respond to the start or control request in a timely fashion.

I have a similar problem w/ Mongo, which is much simpler.

From a command prompt typing:

c:/mongodb/bin/mongod

successfully starts the mongo server.

But trying to install a service as :

sc create mongo binPath= c:\mongodb\bin\mongod.exe

crashes on start everytime with the same error as above.

share|improve this question
    
Do you really need it to be a services, or do you just need it to start when the computer starts? You may be better off setting up a schedule task that is ran when the computer starts. –  Zoredache Sep 21 '10 at 0:42

1 Answer 1

up vote 2 down vote accepted

You can't create a service pointing at a batch file. Create the service pointing to the ringo app, then edit the registry and give it the needed parameters. Set a system wide variable to the value that you need. That should allow the service to start.

share|improve this answer
    
I have the same problem with Mongo which isn't a batch file. –  Scott Sep 21 '10 at 0:29
    
It may just be poor error reporting for different reasons. –  Scott Sep 21 '10 at 0:29
    
Let's forget Mongo for the moment. Am I able to have the service spawn a batch file AFTER it's been started? The trouble is that I have to set a variable in the LOCAL scope of the app so a system wide variable will conflict with other apps - hence the batch file. –  Scott Sep 21 '10 at 0:37
    
No, the service won't be able to run a batch file. What you could do is throw together a small .NET app and have it set the local variable then launch the app. Can you run the app under a local user account? How about setting up an account and setting up a user variable with the correct setting. That way it won't impact other apps on the system unless they are run under that specific local account. –  mrdenny Sep 21 '10 at 6:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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