Windows服务启动后启动脚本 [英] Launch script after Windows service start

查看:134
本文介绍了Windows服务启动后启动脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows服务启动或重启后启动脚本。
像监视器wsupdate一样,在启动或重新启动时执行批处理脚本test.bat

I would like to launch script after windows service start or restart. Like monitor wsupdate and at start or restart execute a batch script test.bat

任何想法吗?

推荐答案

这可以通过计划任务轻松完成:

That could be easily done with a scheduled task:

您只需要:

1)启动和停止服务以在事件日志中获取适当的事件。

1) Start and Stop the Service to got the appropriate Events in the Eventlog.

2) taskchd.msc并创建一个新的Costum Task。作为触发器,您可以选择使用开始和/或停止操作创建的事件。

2) taskschd.msc and create a new Costum Task. As Trigger you can select the Events created before with the start and/or stop action.

3)在操作调用您的cmd / bat时,

3) As Action call your cmd/bat, whatever you want.

提示:
您还可以将事件导出为XML格式,在此处进行解释:
http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx
,然后将XML代码段导入到Scheduld任务中。

Hint: You also can export the Event in the XML Format, explained here: http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx and then import the XML Snippet into the Scheduld Task.

这篇关于Windows服务启动后启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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