Click here to Skip to main content
15,886,001 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
How to convert console application to run as a service? I have the console application working, how to make the same application to run as a service??
Posted
Comments
Nish Nishant 26-Apr-11 7:53am    
Reasonable question. Voted 5 to counter the 1 vote.

It depends on what your console app does right now. Typically you'd need a service if you need some kind of TCP service, remoting server, WCF service etc. Essentially you have code that can be activated when desired. Since you've asked this question I guess we can assume that right now you have a console app, that blocks (perhaps on a key-press) and keeps a thread alive. If so, follow Nijboer's suggestions. If not, you need to explain what you are trying to achieve.

[Edit]
~~~~~~~~~~~

Based on OP's comment, here's a link to an article that shows how to create and install a service using VB.NET:

http://msmvps.com/blogs/joacim/archive/2009/09/13/creating-a-windows-service-using-vb-net.aspx[^]
 
Share this answer
 
v2
Comments
Gokulnath007 26-Apr-11 7:50am    
My Console application will take screenshots in the interval of 10 seconds and stores it in the local drive. I want my console application to run as a service. How to do it?
Nish Nishant 26-Apr-11 7:52am    
See http://msmvps.com/blogs/joacim/archive/2009/09/13/creating-a-windows-service-using-vb-net.aspx

It will teach you how to create and install a service using VB.NET.
Sergey Alexandrovich Kryukov 26-Apr-11 16:49pm    
Good points, my 5.
--SA
You simply create a service project and instead of writing to the console you write to the message log. There are many examples/articles on how this can be done.

Good luck!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Apr-11 16:48pm    
By far not that simple (don't create delusions), but the idea of using message log is right. My 4.
--SA
E.F. Nijboer 27-Apr-11 5:09am    
That's very correct, except that are the simple steps to take to start off. Just pointing them in the right direction, leaving room to find out the details about it. When someone will get stuck, then they can ask again about that.
Sergey Alexandrovich Kryukov 27-Apr-11 11:10am    
Oh, sure, no doubt against your approach. I only suggested not to create the delusion of simplicity. Log is not the main output which is in console application. All I/O is network of pipes or something -- IPC; and the methods are way more complex.
--SA
E.F. Nijboer 27-Apr-11 11:21am    
Very correct, but that is mentioned in most of the articles about them, like this one (but I understand your point):
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
Sergey Alexandrovich Kryukov 27-Apr-11 15:16pm    
Sure. It this article is good, it belongs to the body of your answer.
--SA

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