views:

20

answers:

2

I have to host a console program which hosts an application used by Asp.Net 4.0 and should always be running. What is the best way to host it on the server? I can run the console application from commandline but it can be closed accidently.

Windows Service is not an option as we don't have the source code for the Console App.

+1  A: 

Set up a scheduled task on the machine to run under a "service-like" account when the system is started up. The account should be one that nobody ever logs into so accidental closing should never happen.

Agent_9191
+2  A: 

You don't need the source code to run the app as a service; there are several different ways you can configure any executable to run as a Windows service.

There's the classic method with ResKit tool SRVANY.EXE (and yes, it works with more modern versions of Windows), or you can use SC.EXE.

ewall
@ewall: I tried creating the service using "SC create" command and the service was created.But it did not start. I got the following error.Error 1053: The service did not respond to the start or control request in a timely fashion.
Amitabh
Hmm... did you see if the executable started (e.g. with Process Explorer or similar)? If so, did it leave behind any error logs? Or, if not, then you'll want to check the paths, parameters, etc. There could be other challenges, too--for example, the LocalService (i.e. SYSTEM) account is restricted from network access, so if the program you're trying to run as a service is trying outbound access it is likely to fail unless you run it under another account (like NetworkService or a user account).
ewall