On a listserv I am a member of recently someone asked about the app that could be used to convert applications into services. I realized that this is probably good for all sorts of people to read because many don’t understand it. Here is an adjusted form of the note.
Question: I need an app to run another app as a service….
Some folks mistakenly documented that sc and instsrv would make apps into services, this is not true. They simply call the install routines in a bin that was actually written to be a service.
A service is a special kind of application that has a special launch mechanism included with it. It listens to something called the Service Control Manager (aka the SCuM) and sends info back to it about its status. When you ask the system to stop, start, pause, continue a service you are telling the SCM and it is telling the application. Consequently, not every app can run directly as a service.
So back in the NT4 day MS came up with an app called SRVANY. It is included in the resource kit tools which you can download here. You simply set up some registry entries and voila, instant “crutched” service.
Again, Srvany has been around 10 years, it is the only app MS has that tries to take on the task of making some random app into a service. It will succeed with most but not all apps. It depends on how the app itself responds to various windows messages. There are other third party apps that have the same functionality as SrvAny.
This is not paradise though. There is no application guaranteed to make any other app run as a service. It just can’t be done because the app is simply crutched into being a service and is in fact not really a service and has no clue it is being run that way. If the app directly responds to the windows messages that signal logoff, shutdown, etc the app goes off and does what it wants instead of listening to the “controller” service. This means the app will not “live” past a logoff.
Another issue is that you should be careful if your app does things like opens files in write mode, etc because when the service crutch apps are told to stop they tend to be harsh with the app they are crutching. This is because the app really isn’t aware of being a service and has no way to receive any of the messages sent to the service. The crutch app intercepts them and simply starts and stops the app to align with those specific commands. If the app has cached a bunch of data and is forcibly terminated, you may lose some info or possibly corrupt files. I have seen multiple cases where little proprietary DB apps blew apart their DBs when crutched to run as a service.
Obviously the best way is to have an app that IS a service. The perl SDK has a nice little perl service routine which will turn perl scripts into services (native code) which respond properly. Also VS 2003 added the ability to easily (wizard and supporting classes) make services with VB and C# however that will be NET based and may not excite you. Borland Builder has had the ability to make native code C++ services easily (wizard and supporting
classes) for years (at least three versions so almost 10 years as well).
A popular third party faux service tool is firedaemon. That has been around quite a while, but not as long as srvany.
Here are some others but I am not familiar with them
http://www.sharewareconnection.com/titles/srvany.htm