Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to add a dependency to my service so that it only tries to start after most of the Windows services have started. Can anyone recommend such a service that is unlikely to have been disabled for security reasons on corporate sites. As my service needs the networking services up and running I want to make sure mine starts after these. This service may also be deployed in non-corporate environments so I’m looking for a suitable service that is unlikely to have been disabled by the end user.

share|improve this question

3 Answers 3

Use the Windows Task Scheduler to start your application. Do not add a dependency to it. It would make sense if the application indeed had such a dependency. But since this is not a formal dependency, it's not the correct thing to do.

Furthermore, you cannot guarantee windows services execution order. Only those who have themselves dependency rules are guaranteed to run on a specific order. All others aren't. Which means during the course of several reboots, the last windows service to be executed may vary.

Instead, under the Task Scheduler you can set your task to execute only if a user is logged in, have it run only once, and create a trigger to delay execution of the task to a few seconds.

10 or 20 seconds is enough to guarantee the task is executed last or close to last, having it set to execute only after a user logs in.


You can however search your Event Viewer logs as a basis for a task Scheduler rule. "Only run after this Event fired".

share|improve this answer
    
The task scheduler is a piece of crap. I wouldn't depend on it for anything. You're much better of just putting it in the start up items, or some other hack, than depending on the task scheduler. –  Satanicpuppy Nov 6 '09 at 16:01

You say your service "needs network services up and running". But does it really? Does it just need the various IP related services to be running even if they don't have link or a valid IP address?

Or is your service actually expecting to be able to instantly connect to an external service right when it starts up? And if so, what happens if that external service is down? What happens if there are network connectivity problems somewhere along the route? Does it give up and crash or stop?

In my experience most of the time when people write services and try to make them dependent on other built-in services, what they're really doing is trying to avoid having to write proper error handling code. I don't know what your service actually does, so I can't offer advice about how to handle the multitude of ways that network connectivity wouldn't be working even though the local services are up and running. But you should really think about why you think your service needs this dependency. Isn't there a better way to write it so that you can gracefully handle the condition where the network isn't available?

share|improve this answer

I would suggest the Windows Update service. It's very unlikely to have been disabled.

On Vista and Windows 7 it's even defined as "Automatic (Delayed Start)", so it will start well after all other services.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.