WinService按计划启动但在20秒内停止 [英] WinService Started on Schedule but stopped in 20 seconds

查看:79
本文介绍了WinService按计划启动但在20秒内停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个WinService并在Scheduled Tasks上设置它的启动和停止。但是,每天服务启动大约20秒后,即使在计划任务中,如果启动失败,我也会重新启动,它会自动停止而不会发出任何警报。因此,我必须每天早上手动重新启动服务。现在,我想编写一个可以执行以下任务的批处理文件:

1)检查WinService的运行位置

2)如果不在1),启动服务

3)写下1)和2)的记录。

我确实从网站上读了几个帖子,但是我找不到一个提供好的帖子跟进程序。如果你可以分享你的经验,我将不胜感激。

I created a WinService and set up its start and stop on Scheduled Tasks. But everyday after the service is started for about 20 seconds, it automatically stops without any alert even though in Scheduled Task I did setup re-starting if starting fails. Therefore, I have to re-start the service manually everyday morning. Now, I want to write a batch file that can implement the following tasks:
1) Check where the WinService is running
2) If not in 1), start the service
3) Write the record for 1) and 2).
I did read a couple posted threads from websites, but I have not found one one that provides a good procedure to follow up. If you can share your experience on it, it will be greatly appreciated.

推荐答案

你不需要编写这样的批处理文件。相反,您需要修复您的服务。您可以设置服务,以便在每次加载Windows时自动启动。您永远不需要手动启动服务。即使您编写此批处理文件,它也无济于事,因为您的服务无法正常工作;从您的描述中可以看出这一点。



您要做的就是滥用超出任何合理规模的技术。



-SA
You don't need to write such batch file. Instead, you need to fix your service. You can set up your service for auto-start each time Windows is loaded. You should never be in the need to manually start a service. Even if you write this batch file, it won't help you, because you service is not working properly; this is apparent from your description.

What you are trying to do would be the abuse of technology above any reasonable scale.

—SA


这篇关于WinService按计划启动但在20秒内停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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