run windows services in specific order

2019-05-14 14:32发布

问题:

Is it possible to change the order of windows services or run one service after another?

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?

Thanks!

回答1:

If you're running Server 2008 / Vista / 7 you can set the IIS service for delayed start.

There are sort of two tiers: first all the "automatic" stuff, then the "automatic (delayed start)" stuff.



回答2:

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.

Here's how to set dependencies with Registry edits , from the command-line (sc config ServiceName depend=servicetoDependOn), and from .NET.