0

I would like to know if there is any way of running an operation (like, calling a batch file) before a service is started using services.msc?

I want my batch file to run before the service (tomcat installed as service) is actually started, when the user manually clicks 'Start' in Services.

I don't know if this is possible or not. Thank you for your help in advance!

fleur
  • 115
  • 1
  • 12
  • 1
    I think this may be your answer. http://stackoverflow.com/questions/361097/c-sharp-service-cannot-execute-batch-file – Bull Feathers Feb 13 '12 at 18:53
  • @BullFeathers Thanks, but I was actually aiming not to modify the service itself. Perhaps, if there's an existing batch file that i can configure to call my batch file every time tomcat starts, that would be better. – fleur Feb 14 '12 at 04:01

1 Answers1

0

The answer to your question is NO, unless you want to modify Apache's procrun (which is written in C language).

Depending on what you wanted to do, you should also check my answer here.

One possible way of doing something when a web application is started - on top my mind - would be to write a javax.Servlet.ServletContextListener as explained here. In you listener's contextInitialized() you would start your BAT file via Runtime.exec() as explained here.

Community
  • 1
  • 1
Cebence
  • 2,406
  • 2
  • 19
  • 20