Clone this wiki locally
The structure of the XML file is as follows:
<service> <id> <name> <description> <executable> <arguments> <env> <interactive>
Specifies the ID that Windows uses internally to identify the service. This has to be unique among all the services installed in a system, and (while I haven’t verified this) this must consist entirely out of alpha-numeric characters.
Short display name of the service, which can contain spaces and other characters. This shouldn’t be too long, like <id>, and this also needs to be unique among all the services in a given system.
Long description of the service.
This element specifies the executable to be launched. It can be either absolute path, or you can just specify the executable name and let it be searched from
PATH (although note that the services often run in a different user account and therefore it might have different
PATH than your shell does.)
Delayed loading of the service is possible with multiple optional <depend> elements referring to other service ids.
Optionally set a different logging directory with <logpath> and startup <logmode>: reset (clear log), roll (move to *.old) or append (default).
This element specifies the arguments to be passed to the executable. To pass in multiple arguments, separate them with whitespace, like `<arguments>foo bar zot</arguments>`
To make it easier to comment for example debug arguments you can use multiple optional <argument> elements.
If you need different startup and shutdown arguments, such as
catalina.bat run vs
catalina.bat stop, you can supply them with multiple optional <startargument> and <stopargument> elements.
’’’Note’’’: when <argument>, <startargument> or <stopargument> elements are used the </arguments> element is ignored/no longer required.
This optional element can be specified multiple times if necessary to specify environment variables to be set for the child process. The syntax is:
<env name="HOME" value="c:\abc" />
If this optional element is specified, the service will be allowed to interact with the desktop, such as by showing a new window and dialog boxes. If your program requires GUI, set this like the following:
<service> <id>fisheye</id> <name>dev.net FishEye</name> <description>FishEye</description> <executable>%FISHEYE_HOME%\bin\fisheyectl.bat</executable> <logpath>P:\dev\logs\os\windows\services</logpath> <logmode>roll</logmode> <depend>Spooler</depend> <startargument>run</startargument> <stopargument>stop</stopargument> </service>
Environment variable expansion
All the text values in this XML can include environment variable expansions of the form
%NAME%, like Windows batch files. Such an expression is replaced by the actual value of the environment variable.
Also, the service wrapper sets the environment variable
BASE by itself, which points to a directory that contains the renamed
winsw.exe. This is useful to refer to other files in the same directory. Since this is an environment variable by itself, this value can be also accessed from the child process launched from the service wrapper.