views:

195

answers:

5

I have a windows application that I want to run as a windows service - how can I do this ?

+1  A: 

Quick-n-dirty way, use the INSTSRV and SRVANY tools in the Windows Resource Kit: How To Create a User-Defined Service

Patrick Cuff
+2  A: 

You can use a tool to do this: XYNTService.

It is a service that can start regular applications, we use it at work and it also works with GUI apps. Since the service is running under the local SERVICE account, you can not see the GUI or access it in any way, because it is running in another winlogon session.

Treb
A: 

Solution for a .Net application that you have the source code:

If you project have a Controller and Business Logic well seperated (MVC) this will be very easy and fast.

First, create a new project in your solution and select "Windows Service". This will create you a new project with a Program class that will contain a Main.

Inside the Main you need to attach the Service Base class.

static class Program
{
 static void Main()
    {
        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()};
        ServiceBase.Run(ServicesToRun);       
 }
}

Inside your service (the one who extend ServiceBase you need to override:

protected override void OnStart(string[] args)

To call your controller to start the job or you can simply start at while(...) with a thread.

Otherwise, the link from Patrick Cuff is the good one.

Daok
A: 

Hi Ebircsa.

In addition to XYNTService and SRVANY already recommended, you should consider AlwaysUp, a commercial product designed to run any application as a Windows Service. You can try it free for 30 days to ensure that it will do the job for you.

Good luck!

CoreTech
A: 

Try this:

http://support.microsoft.com/kb/137890

It would work for any version of Windows. I've recently tested it with Server 2008.

Yakov Lipkovich