Windows service
From Wikipedia, the free encyclopedia
A Windows service is an application that starts when Windows is booted and runs in the background as long as Windows is running. It is very similar in concept to a Unix daemon.
Contents |
[edit] Background
Windows provides an interface called the Service Control Manager that manages creating, deleting, starting and stopping of services. An application that wants to be a service needs to first be written in such a way that it can handle start|stop|pause|... messages from the windows service control manager. Then, in one or more API calls, the name of the service and other attributes such as its description are registered with the Service Control Manager. In Windows Vista, users can also manipulate services through a simpler interface in MSConfig. [1]
[edit] Starting/Stopping/Modifying a Windows Service
Once a service is installed, its attributes can be modified by launching "Services" from the Windows Control Panel Administrative tools.
[edit] User Permissions and Implementation Considerations
Windows services by default are run as a virtual user: "LocalSystem" that has administrative rights on the system. The working directory will be the Windows system directory (typically C:\WINNT) and the default temp directory will typically be C:\WINNT\TEMP.
Since this is not a real user, this presents some challenges if user-specific data needs to be stored by the application, as there is no home directory for this user. LocalSystem also has no access to network file shares and similar resources; if a service needs to access files on the network, it generally needs to be configured to run as a domain user with access to those files.
Windows services can be set up to run as any user although running as a user other than the default requires storing a password. It is important to consider that as soon as the password is changed, the service will not run unless the password provided for the service is also changed.
When a service runs as LocalSystem, Windows allows the user to configure it so it is "allowed to interact with desktop" (that is, display user-visible dialog boxes and other windows). However, if running as any other user, this option is not available.
[edit] External links
- MSDN - Microsoft's MSDN Library Documentation on Services
- INSTSRV.EXE - a Windows resource kit program that allows you to install an arbitrary application as a service
- SrvAny/InstSrv Tutorial - SrvAny and InstSrv Tutorial with many Screenshots
- FireDaemon - a very popular commercial service installer / runner that is much easier to use than SrvAny/InstSrv
- Eltima Application As Service - a "swift and powerful" commercial tool that makes any application run as Windows service