按特定顺序运行 Windows 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6155913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
run windows services in specific order
提问by dpac
Is it possible to change the order of windows services or run one service after another?
是否可以更改 Windows 服务的顺序或运行一个又一个服务?
The reason i want this: I have IIS configuration located on a shared drive. And when i reboot server, it first run IIS (w3wp) service and couldn't start it. because at that point, shared network drive is not available. So i want to first finishing the network service to map all network drives and then run IIS service. so i don't need to restart IIS service every-time i reboot the server. is there any other way to achieve this?
我想要这个的原因:我的 IIS 配置位于共享驱动器上。当我重新启动服务器时,它首先运行 IIS (w3wp) 服务并且无法启动它。因为那时,共享网络驱动器不可用。所以我想先完成网络服务映射所有网络驱动器,然后运行IIS服务。所以我不需要每次重新启动服务器时都重新启动 IIS 服务。有没有其他方法可以实现这一目标?
Thanks!
谢谢!
采纳答案by trutheality
If you're running Server 2008 / Vista / 7 you can set the IIS service for delayed start.
如果您运行的是 Server 2008 / Vista / 7,您可以将 IIS 服务设置为延迟启动。
There are sort of two tiers: first all the "automatic" stuff, then the "automatic (delayed start)" stuff.
有两层:首先是所有“自动”的东西,然后是“自动(延迟启动)”的东西。
回答by ewall
By default, some Windows services are configured with "dependencies" to ensure that the prerequisite services are started first... so you can just add to them.
默认情况下,某些 Windows 服务配置了“依赖项”以确保先决条件服务首先启动......因此您可以添加到它们中。
Here's how to set dependencies with Registry edits, from the command-line(sc config ServiceName depend=servicetoDependOn
), and from .NET.
以下是如何通过注册表编辑、命令行( sc config ServiceName depend=servicetoDependOn
) 和.NET设置依赖项。