Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Comments
Sergey Alexandrovich Kryukov 3-Aug-11 18:26pm    
This is quite possible, but I want to know why? I suspect (or actually pretty much sure) the whole approach is wrong.
--SA
bobishkindaguy 4-Aug-11 2:27am    
@SAKryukov: I have created a client/server system where there is one server and many clients, on many computers. Each client needs the server program to be running. So instead of "worrying" that the server program might not have been started, or telling the user to "go over and start the server program", I am thinking of ways to ensure that 1. it is either very likely to have been started, by making a service run it upon boot, and 2. the service can respond to a request from client (using .Net Remoting) and start the server program. I have been looking at XYNTService now. I might be able to modify that to include the .NET Remoting functionality.

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.
 
Share this answer
 
Comments
Dylan Morley 4-Aug-11 8:21am    
spot on, 5
So in VS2010, using the ServiceProcessInstaller class, I found this line of code:
myInstaller.ServicesDependedOn = new string [] { "CLIPBOOK" }; 


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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900