views:

11402

answers:

6

In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.

Can this batch file be run as a service? I am experimenting with one of the suggestions from a similar question.

+6  A: 

See RunAsService.

Doug Currie
@Doug - If I could +10 you, I would. Thanks.
Kyle Rozendo
+1  A: 

As Doug Currie says use RunAsService.

From my past experience you must remember that the Service you generate will

  • have a completely different set of environment variables
  • have to be carefully inspected for rights/permissions issues
  • might cause havoc if it opens dialogs asking for any kind of input

not sure if the last one still applies ... it was one big night mare in a project I worked on some time ago.

lexu
A: 

While it is not free (but $39), FireDaemon has worked so well for me I have to recommend it. It will run your batch file but has loads of additional and very useful functionality such as scheduling, service up monitoring, GUI or XML based install of services, dependencies, environmental variables and log management.

I started out using FireDaemon to launch JBoss application servers (run.bat) but shortly after realized that the richness of the FireDaemon configuration abilities allowed me to ditch the batch file and recreate the intent of its commands in the FireDaemon service definition.

There's also a SUPER FireDaemon called Trinity which you might want to look at if you have a large number of Windows servers on which to manage this service (or technically, any service).

Nicholas
+6  A: 

Why not simply set it up as a Scheduled Task that is scheduled to run at start up?

Stephen Martin
I have a number of batch files doing backups via robocopy that I start via the Scheduled Tasks (go to Control Panel, Scheduled Tasks) running on a Win 2003 server. Works a treat...
SAL
A: 

Hi Ravi.

AlwasyUp will easily run your batch file as a service. It is similar to FireDaemon (mentioned above) and isn't free, but you may find the rich feature set to be an asset in a professional environment.

Good luck!

CoreTech
A: 

I tried RunAsService And the service successfully started my batch file, but my case is that : My batch file executes python code and this python code instantiate a java process so the process tree when running RunAsService is like :

+RunAsService
    +python
       +java

when I manually Stop the service it killed the RunAsService process only and left the rest of tree (python) and (java) processes, so my application still running, and its a problem.


I also tried the Instructions here http://www.mike-tech.com/article.php?gif=win2k&article=135

the process tree wals like :

 +srvany
   +cmd
     +python
       +java

When i manually STOP the service It killed (srvany) process and its first child (cmd) and left (python) and (java) process still alive.


The FireDaemon really worked fine and killed the whole tree when stopping the service..But It's not free :S

Is there any other way taht I can kill the whole tree in Service Stop, or any free software like FireDaemon ??

Montaro