当用户在services.msc中手动启动服务时,在tomcat服务启动之前运行批处理文件 [英] Running a batch file before tomcat service starts when user manually starts the service in services.msc

查看:124
本文介绍了当用户在services.msc中手动启动服务时,在tomcat服务启动之前运行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在使用services.msc启动服务之前是否有任何方式运行操作(例如,调用批处理文件)?

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?

当用户在服务中手动单击开始"时,我希望我的批处理文件在实际启动该服务(作为服务安装的tomcat)之前运行.

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!

推荐答案

除非您要修改Apache的procrun(用C语言编写),否则问题的答案为.

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.

启动Web应用程序时,做某事的一种可能方法-我想是-写javax.Servlet.ServletContextListener,如此处中的说明通过Runtime.exec()启动BAT文件.

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.

这篇关于当用户在services.msc中手动启动服务时,在tomcat服务启动之前运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆