Pages

Running applications as a service on Windows 2008 or SBS 2008

Recently I was presented a challenge of making an application run as a service. That part is usually not to hard, we can use the free Windows NT Resource Kit utilities and SRVANY.EXE to accomplish this. Many great how to’s have been written on this, and I will include links at the end to some of these great articles. But what happens when SRVANY.EXE doesn’t allow the program to run correctly?

Doing a little research, I came across this little freeware application that helped out. It’s called Winserv and is free and open source. To get the tool, visit http://www.sw4me.com/wiki/Winserv . Once downloaded, I used the command line Winserv install MyServiceName PathToExecutable . That seemed to work as far as getting the application to load, but in my case, the remote programs that connected to this application still did not work. I got out RegMon by Mark Russinovich to see if I could trace why it was not working. Upon running this tool, I noticed that when the application ran via Winserv it was looking for a registry key that simply didn’t exist.

Doing a little more digging, I decided to run the application with Interactive Mode enabled. (Inside the services.msc for my new service called MyServiceName is “Allow service to interact with desktop”). So checked this box, then re-ran the service. This time, Windows prompted me to see the interactive application. I clicked on it and selected it, and the actual application I was running via the service was prompting me for information. This turned out to be the registry keys that RegMon indicated to me. I filled out the requirements the application wanted, and then closed the app. This time I turned off Interactive Mode and re-ran the service. I then tested my clients application and it worked as expected.

As I couldn’t leave good enough alone, I decided to remove WinServ and use the built in SRVANY.EXE application doing the same steps with Interactive Login. It didn’t work. So I reverted back to WinServ and the application worked as expected, even on a x64 server.

Links:
http://www.iopus.com/guides/srvany.htm
http://www.tacktech.com/display.cfm?ttid=197
http://support.microsoft.com/kb/q137890/

4 comments to Running applications as a service on Windows 2008 or SBS 2008