我需要一个等待SQL Server启动的服务,然后启动我指定的程序 [英] I need a service that waits for SQL Server to start, then starts a program I specify

查看:73
本文介绍了我需要一个等待SQL Server启动的服务,然后启动我指定的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确保只要Windows启动,可执行文件就会启动.但是有一些并发症.

是否有人创建了"Windows服务",如果满足以下条件之一,它可以延迟启动"指定的可执行文件:

1.从计算机启动以来已经过去了x分钟,以便有时间放置其他内容(例如sql server)

2.或实际上循环检查sql server是否已启动,而不是等待x分钟

作为第二个目标,我将尝试向该服务添加WCF组件,该组件可以手动"从另一台计算机上的程序按需"启动exe.如果我能完成这些任务,并且没有人创建一篇文章可以分享此内容,那么我将为此撰写一篇文章.

I need to ensure that an executable starts whenever windows starts. But there are a couple of complications.

Has anyone created a "windows service" that can "delay start" a specified executable if one of these conditions are met:

1. x minutes has passed since the computer started, to give time for other stuff to be in place such as sql server

2. or actually loop to check if sql server has started instead of waiting for x minutes

As a second objective, I will try and add to this service a WCF component that could "manually" launch the exe "on demand" from a program on another computer. If I can accomplish these, and no one else has created an article to share this, I will contribute an article for this.

推荐答案

Windows服务彼此依赖.这意味着一项服务必须先启动,然后另一项才能启动.

如果我了解您的要求,那么您的服务器进程就可以作为服务编写.安装后,该服务将依赖SQL Server服务先启动.

打开Services.msc,并获取IP Helper或Security Center服务上的属性作为示例.显然,您正在寻找依赖项"选项卡.
Windows Services have dependencies on each other. This means that one service must start before another can start.

If I understand your requirements, your server process could just be written as a service. When installed, that service would depend on the SQL Server service(s) to start first before it does.

Open Services.msc and get properties on the IP Helper or Security Center services for examples. You''re looking for the Dependencies tab, obviously.


因此,在VS2010中,使用ServiceProcessInstaller类,我发现了以下代码行:
So in VS2010, using the ServiceProcessInstaller class, I found this line of code:
myInstaller.ServicesDependedOn = new string [] { "CLIPBOOK" }; 



我看到这里的依赖关系用引号引起来,所以我假设我必须确定在我的服务之前需要运行哪些sql server服务,并按上述方式添加它们而没有文件系统后缀;例如"MSSQLSERVER".

看起来正确吗?



I see the dependency here is in quotes, so I assume I would have to determine which sql server service(s) need to be running before my service, and add them as above without a file system suffix; e.g. "MSSQLSERVER".

Does that look right?


这篇关于我需要一个等待SQL Server启动的服务,然后启动我指定的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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