Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All

I have created one console application,having some ref dll.

How to host executable (Console application exe) in windows service?


Happy Holi.......... :)
Posted
Updated 16-Mar-14 23:52pm
v3
Comments
Richard MacCutchan 17-Mar-14 5:44am    
You don't, you have to make it into a service. Normal executable windows programs cannot run as services.
$*Developer - Vaibhav*$ 17-Mar-14 5:53am    
sorry its console application
Richard MacCutchan 17-Mar-14 6:03am    
Still the same answer. If you want to run your program as a service, then you need to build it according to the rules for service programs. This is all documented on MSDN.
Krunal Rohit 17-Mar-14 5:51am    
What are you trying to achieve by the way ?

-KR
$*Developer - Vaibhav*$ 17-Mar-14 5:56am    
Application run 24*7 if system restarts the service runs or start automatically

Here are three suggestions:

1. Update your console app so that it can run as a service. (Best)

2. Create a generic Windows Service which executes your console app and restarts it if it crashes etc. (Not so good)

3. Forget about Windows services and use the task scheduler to start your console app when Windows starts. I've used this a lot for hackier solutions. You can configure it to start up when Windows does, without the need for anyone to log on, it will span user sessions and you can configure it to restart if it fails. The end result is very similar to a Windows Service although obviously it won't appear in the SCM and you can' stop/start/pause it etc. (EASY!)
 
Share this answer
 
Comments
Bernhard Hiller 17-Mar-14 11:06am    
Wow, that was a heavy downvote, twice as valid as my vote... Looks like someone insists in ideological purity, thus strongly disapproving "hacky solutions".
Rob Philpott 17-Mar-14 12:13pm    
Or, more likely, they are an idiot!
You cannot host a windows executable in a windows service.
Convert the application to a service.
 
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