<p>I have an existing GUI application that should have been implemented as a service. Basically, I need to be able to remotely log onto and off of the Windows 2003 server and still keep this program running.</p>

<p>Is this even possible?</p>

<p>EDIT: Further refinement here... I do not have the source, it's not my application.</p>

[{'answer_id': 53236, 'author': 'Mark Brackett', 'author_id': 2199, 'author_profile': 'https://Stackoverflow.com/users/2199', 'pm_score': 3, 'selected': False, 'text': '<p>You can wrap it up into <a href="http://support.microsoft.com/kb/137890" rel="noreferrer">srvany</a>, though you may need to assign it an actual user account (as opposed to LocalService or some such)</p>\n'}, {'answer_id': 53288, 'author': 'Brad Bruce', 'author_id': 5008, 'author_profile': 'https://Stackoverflow.com/users/5008', 'pm_score': 0, 'selected': False, 'text': "<p>Do you have the source?  In many cases the difference between a stand alone application and a service are minimal.</p>\n\n<p>Most of the changes are related to hooking the code into the service manager properly.  Once done, you'll know that any problems that occur are a result of your programming and not any other program.</p>\n"}, {'answer_id': 53339, 'author': 'McKenzieG1', 'author_id': 3776, 'author_profile': 'https://Stackoverflow.com/users/3776', 'pm_score': 4, 'selected': False, 'text': '<p>Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application. If you have the source code, converting the non-GUI code into a service is easy - Visual Studio has a \'Windows Service\' project type that takes care of the wrapping for you, and there is a simple walkthrough that shows you how to create a deployment project that will take care of installation.</p>\n\n<p>If you opt for the second route and need to put some of the original GUI code into a controller, the controller and service can communicate via WCF, .NET Remoting or plain socket connections with a protocol you define yourself. If you use Remoting, be sure to use a "chunky" interface that transfers data with as few method invocations as possible - each call has a fair amount of overhead.</p>\n\n<p>If the UI is fairly simple, you may be able to get away with using configuration files for input and log files or the Windows Event Log for output.</p>\n'}, {'answer_id': 53346, 'author': 'Craig Tyler', 'author_id': 5408, 'author_profile': 'https://Stackoverflow.com/users/5408', 'pm_score': -1, 'selected': False, 'text': '<p>First I would have to ask why your service needs a user interface. Most likely it does not but you probably need a client that gets data from this service. The reason services don\'t usually have GUI\'s is they may not have a window environment to run in. Services can start and run without a user logged in to the machine. In this case there would be no desktop for the service GUI to run in.</p>\n\n<p>Having said that you can set properties on the service to run as a user as suggested by Mark. You can also specify in the properties of the service to "Allow service to interact with desktop". Only do this if you know a user will be logged in.</p>\n'}, {'answer_id': 53413, 'author': 'David L Morris', 'author_id': 3137, 'author_profile': 'https://Stackoverflow.com/users/3137', 'pm_score': -1, 'selected': False, 'text': "<p>A service shouldn't have a GUI, since it should run without any needing any intervention from a user, and there are all sorts of problems associated with finding and communicating with the correct users desktop.</p>\n\n<p>Since, presumably the reason for asking this is to be able to remotely monitor the application, the way to do it would be to have two applications.  The service side (written basically as a console application) and the client/monitoring GUI side.  The service would use some remote connectivity (when I did this I used Named Pipes) to communicate with the client/monitoring application.  Either should be able to run without the other, and certainly the service should be able to run with out the client.</p>\n"}, {'answer_id': 53800, 'author': 'JeffV', 'author_id': 445087, 'author_profile': 'https://Stackoverflow.com/users/445087', 'pm_score': 3, 'selected': False, 'text': '<p>Has anyone used a third party product like: <a href="http://www.coretechnologies.com/products/AlwaysUp/" rel="noreferrer">Always Up</a>?</p>\n\n<p>Seems to do what I need. It\'s the capability to keep running through login / logout cycles I need. And the capability to ignore that it\'s a GUI app and run it anyway.</p>\n\n<p>They must be linking into the exe manually and calling WinMain or something.</p>\n'}, {'answer_id': 57523, 'author': 'Aardvark', 'author_id': 3655, 'author_profile': 'https://Stackoverflow.com/users/3655', 'pm_score': 0, 'selected': False, 'text': "<p>What happens if you create a service. That service is configure to interact with the desktop. Configure it to run a some user and to start automatic. From the service CreateProcess on this other application. I'd guess this is quick to try using C# (C/C++ was alot of code to even be a service if I recall). Would that work??</p>\n\n<p>BUT!</p>\n\n<p>My first thought would be to create a virtual computer in a server-class virtual host (like Virtual Server, HyperV, VMWare). Those virtual machines will run as service (or whatever Hyper V does). The virtual machine would always be running - regardless of logging in and out.</p>\n\n<p>Make this virtual computer auto login to windows (TweakUI can set this up) and then just launch the GUI app using a shortcut to the Startup folder. You can even remote desktop into it use the program's GUI (I bet Always Up can't do that).</p>\n"}, {'answer_id': 5147559, 'author': 'joshua', 'author_id': 426600, 'author_profile': 'https://Stackoverflow.com/users/426600', 'pm_score': 2, 'selected': False, 'text': "<p>Do you actually need it to run as a service or do you just need it to stay running when you aren't connected? If the latter, you can disconnect instead of logging off and the application will continue running. The option should be in the drop down list after choosing Shut Down or you can call tsdiscon.exe.</p>\n"}, {'answer_id': 10399063, 'author': 'labilbe', 'author_id': 1195872, 'author_profile': 'https://Stackoverflow.com/users/1195872', 'pm_score': 0, 'selected': False, 'text': '<p>You can use <a href="http://www.activeplus.com/en/Products/ServiceMill" rel="nofollow">ServiceMill</a> to achieve this operation.\nBasically you install ServiceMill Server on your server.\nThen click on right button over your executable file and "Install as a ServiceMill Service".\nNext you configure some things (user/password, if you want to interact with desktop or if you prefer to hide the ui... and set the start mode to automatic).</p>\n\n<p>Another tool from Active+ Software can be a solution, <a href="http://www.activeplus.com/en/Products/ServiceMillExeBuilder" rel="nofollow">ServiceMill Exe Builder</a> which allows you to create services from Command Line and this is great if you are using a Continuous Integration Server or if you plan to distribute your component as a service without having to think about service integration (plus it is royalty free).</p>\n'}, {'answer_id': 35202611, 'author': 'VitalyB', 'author_id': 126574, 'author_profile': 'https://Stackoverflow.com/users/126574', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve had good experience with <a href="https://github.com/kohsuke/winsw" rel="nofollow noreferrer">winsw</a>. I was able to convert quite easily my batch files to services using it.</p>\n\n<p>I\'ve used it for nginx as well, per <a href="https://stackoverflow.com/questions/10061191/how-to-add-nginx-exe-as-windows-system-service-like-apache">this answer</a>.</p>\n'}, {'answer_id': 40825152, 'author': 'IneedHelp', 'author_id': 1123740, 'author_profile': 'https://Stackoverflow.com/users/1123740', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://www.firedaemon.com/product/firedaemon-pro" rel="nofollow noreferrer">FireDaemonPro</a> turns most GUI apps into services; it\'s not free, but it might be worth getting it.</p>\n'}]
['https://Stackoverflow.com/questions/53232', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/445087/']