Class

# ServiceApplication

<div class="rst-class">

forsearch

</div>

Console

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to create a Windows service application, which runs in the background without a user interface.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                      | Type                                 | Read-Only | Shared |
|-----------------------------------------------------------|--------------------------------------|-----------|--------|
| `BugVersion<serviceapplication.bugversion>`               | `Integer</api/data_types/integer>`   | ✓         |        |
| `BuildDateTime<serviceapplication.builddatetime>`         | `DateTime</api/data_types/datetime>` | ✓         |        |
| `Copyright<serviceapplication.copyright>`                 | `String</api/data_types/string>`     | ✓         |        |
| `Description<serviceapplication.description>`             | `String</api/data_types/string>`     | ✓         |        |
| `ExecutableFile<serviceapplication.executablefile>`       | `FolderItem</api/files/folderitem>`  | ✓         |        |
| `MajorVersion<serviceapplication.majorversion>`           | `Integer</api/data_types/integer>`   | ✓         |        |
| `MinorVersion<serviceapplication.minorversion>`           | `Integer</api/data_types/integer>`   | ✓         |        |
| `NonReleaseVersion<serviceapplication.nonreleaseversion>` | `Integer</api/data_types/integer>`   | ✓         |        |
| `ProcessID<serviceapplication.processid>`                 | `Integer</api/data_types/integer>`   | ✓         |        |
| `RegionCode<serviceapplication.regioncode>`               | `Integer</api/data_types/integer>`   | ✓         |        |
| `StageCode<serviceapplication.stagecode>`                 | `Integer</api/data_types/integer>`   | ✓         |        |
| `Version<serviceapplication.version>`                     | `String</api/data_types/string>`     | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                      | Parameters                                              | Returns                            | Shared |
|-------------------------------------------|---------------------------------------------------------|------------------------------------|--------|
| `Daemonize<serviceapplication.daemonize>` |                                                         | `Boolean</api/data_types/boolean>` |        |
| `DoEvents<serviceapplication.doevents>`   | milliseconds As `Integer</api/data_types/integer>` = 10 |                                    |        |

## Events

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                        | Parameters                                                    | Returns                            |
|-------------------------------------------------------------|---------------------------------------------------------------|------------------------------------|
| `DontDaemonize<serviceapplication.dontdaemonize>`           |                                                               | `Boolean</api/data_types/boolean>` |
| `Pause<serviceapplication.pause>`                           |                                                               |                                    |
| `Resume<serviceapplication.resume>`                         |                                                               |                                    |
| `Run<serviceapplication.run>`                               | args() As `String</api/data_types/string>`                    | `Integer</api/data_types/integer>` |
| `Stop<serviceapplication.stop>`                             | ShuttingDown As `Boolean</api/data_types/boolean>`            |                                    |
| `UnhandledException<serviceapplication.unhandledexception>` | error As `RuntimeException</api/exceptions/runtimeexception>` | Boolean                            |

## Property descriptions

<div id="serviceapplication.bugversion">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.BugVersion

**BugVersion** As `Integer</api/data_types/integer>`

> The Bug version of the `ConsoleApplication</api/console/consoleapplication>`. This can only be set in the IDE, but you can read the value in your code.
>
> This property is read-only.
>
> Typically version numbers are written as 1.2.3.4 (MajorVersion.MinorVersion.BugVersion.NonReleaseVersion).
>
> Put all the individual versions together to create the full version:
>
> ``` xojo
> Var fullVersion As String
> fullVersion = MajorVersion.ToString + "." + MinorVersion.ToString + "." + BugVersion.ToString + "." + NonReleaseVersion.ToString
> ```

<div id="serviceapplication.builddatetime">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.BuildDateTime

**BuildDateTime** As `DateTime</api/data_types/datetime>`

> Contains the date and time when the application was built.
>
> You can also access the `CreationDateTime<folderitem.creationdatetime>` property of the application's `FolderItem</api/files/folderitem>` by calling App.ExecutableFile.CreationDate.
>
> This property is read-only.

<div id="serviceapplication.copyright">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Copyright

**Copyright** As `String</api/data_types/string>`

> Copyright information of the <span class="title-ref">ServiceApplication</span>.
>
> Copyright usually contains the application name, version number and copyright information.
>
> This property is read-only.
>
> Logs the app version:
>
> ``` xojo
> System.DebugLog("Copyright: " + App.Copyright)
> ```

<div id="serviceapplication.description">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Description

**Description** As `String</api/data_types/string>`

> The description of the application, corresponding to the version information.
>
> This property is read-only.
>
> This property can be set only in the IDE.

<div id="serviceapplication.executablefile">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.ExecutableFile

**ExecutableFile** As `FolderItem</api/files/folderitem>`

> Points to the actual executable file even if it is inside a bundle.
>
> This property is read-only.
>
> To get the app executable name:
>
> ``` xojo
> Var appName As String = App.ExecutableFile.Name
> ```

<div id="serviceapplication.majorversion">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.MajorVersion

**MajorVersion** As `Integer</api/data_types/integer>`

> The major version of the `ConsoleApplication</api/console/consoleapplication>`, corresponding to the version information. The range is from 0 to 255. This can only be set in the IDE, but you can read the value in your code.
>
> Typically version numbers are written as 1.2.3.4 (MajorVersion.MinorVersion.BugVersion.NonReleaseVersion).
>
> This property is read-only.
>
> Put all the individual versions together to create the full version:
>
> ``` xojo
> Var fullVersion As String
> fullVersion = MajorVersion.ToString + "." + MinorVersion.ToString + "." + BugVersion.ToString + "." + NonReleaseVersion.ToString
> ```

<div id="serviceapplication.minorversion">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.MinorVersion

**MinorVersion** As `Integer</api/data_types/integer>`

> Minor version of the `ConsoleApplication</api/console/consoleapplication>`, corresponding to the version information. The range is from 0 to 255. This can only be set in the IDE, but you can read the value in your code.
>
> Typically version numbers are written as 1.2.3.4 (MajorVersion.MinorVersion.BugVersion.NonReleaseVersion).
>
> This property is read-only.
>
> Put all the individual versions together to create the full version:
>
> ``` xojo
> Var fullVersion As String
> fullVersion = MajorVersion.ToString + "." + MinorVersion.ToString + "." + BugVersion.ToString + "." + NonReleaseVersion.ToString
> ```

<div id="serviceapplication.nonreleaseversion">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.NonReleaseVersion

**NonReleaseVersion** As `Integer</api/data_types/integer>`

> The NonRelease version of the `ConsoleApplication</api/console/consoleapplication>`, corresponding to the version information. Sometimes referred to as the build number. This can only be set in the IDE, but you can read the value in your code.
>
> Typically version numbers are written as 1.2.3.4 (MajorVersion.MinorVersion.BugVersion.NonReleaseVersion).
>
> This property is read-only.
>
> If AutoIncrementVersionInformation is checked, the IDE increases NonReleaseVersion by one each time you build your project, but not when you run it.
>
> Put all the individual versions together to create the full version:
>
> ``` xojo
> Var fullVersion As String
> fullVersion = MajorVersion.ToString + "." + MinorVersion.ToString + "." + BugVersion.ToString + "." + NonReleaseVersion.ToString
> ```

<div id="serviceapplication.processid">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.ProcessID

**ProcessID** As `Integer</api/data_types/integer>`

> Returns the system process ID for the app that you would see in something like Activity Monitor (macOS) or Task Manager (Windows).
>
> This property is read-only.

<div id="serviceapplication.regioncode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.RegionCode

**RegionCode** As `Integer</api/data_types/integer>`

> The Region Code of the application, corresponding to the version information. Not supported on Windows. This property can be set only in the IDE.
>
> This property is read-only.

<div id="serviceapplication.stagecode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.StageCode

**StageCode** As `Integer</api/data_types/integer>`

> Stage Code of the application, corresponding to the version information.
>
> This property is read-only.
>
> Use the four Application class constants to set/get the Stage. Stage can be set only in the IDE.
>
> | Value | Description |
> |-------|-------------|
> | 0     | Development |
> | 1     | Alpha       |
> | 2     | Beta        |
> | 3     | Final       |

<div id="serviceapplication.version">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Version

**Version** As `String</api/data_types/string>`

> Version of the `ConsoleApplication</api/console/consoleapplication>`.
>
> This property is read-only.
>
> This property can be set only in the IDE.
>
> Typically version numbers are written as 1.2.3.4.
>
> Version is displayed by the file information windows on macOS (Finder, Get Info) and Windows (Windows Explorer, Properties).

## Method descriptions

<div id="serviceapplication.daemonize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Daemonize

**Daemonize** As `Boolean</api/data_types/boolean>`

> Converts the app from a regular console app to a daemon process that runs in the background on macOS or Linux.
>
> Since daemonized console apps cannot be run from the IDE, you should build and test as a non-daemonized console app and then daemonize it when you build. Use `System.Log<system.log>` to handle debugging.
>
> Although you can also use the Daemonize method on macOS, Apple would rather you use [launchd](https://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man5/launchd.plist.5.html) to start daemon processes.
>
> To create a background console application on Windows, you need to use <span class="title-ref">ServiceApplication</span>.
>
> A typical use of the Daemonize method is as follows:
>
> ``` xojo
> #If Not DebugBuild Then ' Do not try to daemonize a debug build
>   If (args(1) = "start" Or args(1) = "-d") Then ' Check for command-line parameter to daemonize
>     If Not App.Daemonize Then
>       System.Log(System.LogLevelCritical, "Could not daemonize the app.")
>       Return -1
>     End If
>   End If
> #EndIf
> ```

<div id="serviceapplication.doevents">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.DoEvents

**DoEvents**(milliseconds As `Integer</api/data_types/integer>` = 10)

> Yields time back to your app so that it can handle other events.
>
> ``` xojo
> ' In the Run event of your console application
> Var consoleTimer As New MyTimerSubclass
>
> consoleTimer.RunMode = Timer.RunModes.Multiple ' Don't forget this one
> consoleTimer.Period = 1000 ' Call every second
>
> Do
>   App.DoEvents
> Loop
> ```

## Event descriptions

<div id="serviceapplication.dontdaemonize">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.DontDaemonize

**DontDaemonize** As `Boolean</api/data_types/boolean>`

> Returning `True</api/language/true>` prevents the application from being daemonized.

<div id="serviceapplication.pause">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Pause

**Pause**

> Occurs when the user selects Pause from the Service Control Manager on Windows.
>
> When the user selects Pause, he expects the service to stop performing whatever action it was doing. It should continue to halt execution until the `Resume<serviceapplication.resume>` event is fired.

<div id="serviceapplication.resume">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Resume

**Resume**

> Occurs when the user selects Continue from the Service Control Manager on Windows, assuming that a Pause event has already occurred.
>
> The Resume event is not called unless the <span class="title-ref">ServiceApplication</span> is paused. Use this event to continue running your <span class="title-ref">ServiceApplication</span>.

<div id="serviceapplication.run">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Run

**Run**(args() As `String</api/data_types/string>`) As `Integer</api/data_types/integer>`

> Code in this event is run when the console app starts running. The console app ends when this event finishes.
>
> *args()* is an array of command line parameters that get passed to the application. The first parameter will always be the application itself. The return value will be passed to the operating system as the return value for the entire application. The encoding of *args()* is operating system-specific. On NT-based systems, it is UTF-16. On Linux, it will be UTF-8, and so forth.
>
> On macOS and Linux, the *args()* array contains the passed arguments as *unescaped* and *unquoted* values:
>
> - **Unescaped**: some characters need to be escaped to be passed on a terminal command line, i.e. preceded by a backslash character. *args()* values contain the character without the leading backslash.
> - **Unquoted**: instead of escaping some characters, single-quotes or double-quotes can be used. Quotes are removed in *args()* values.
>
> For example, passing the following command line from a terminal:
>
> ``` plain
> /path/to/my/application -a --name="A quoted string parameter" --file=~/An\\ escaped\\ path
> ```
>
> results in the following *args()* array:
>
> | Value | Description                      |
> |-------|----------------------------------|
> | 0     | /path/to/my/application          |
> | 1     | -a                               |
> | 2     | --name=A quoted string parameter |
> | 3     | --file=~An escaped path          |

<div id="serviceapplication.stop">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.Stop

**Stop**(ShuttingDown As `Boolean</api/data_types/boolean>`)

> Occurs in two situations: When the user selects Stop from the Service Control Manager on Windows or when the computer is shutting down.
>
> If the user selected Stop, *ShuttingDown* is `False</api/language/false>`.
>
> If the computer is shutting down, *ShuttingDown* is `True</api/language/true>`. This event occurs when you call the `Quit</api/language/quit>` method on any platform or when the service terminates. The *ShuttingDown* parameter is supported only on Windows.

<div id="serviceapplication.unhandledexception">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

ServiceApplication.UnhandledException

**UnhandledException**(error As `RuntimeException</api/exceptions/runtimeexception>`) As Boolean

> Occurs when a `RuntimeException</api/exceptions/runtimeexception>` occurs that is not otherwise handled.
>
> This event allows you to do any last-minute clean-up, but the application does not resume after this event. The application terminates after this event.
>
> The UnhandledException event returns a `Boolean</api/data_types/boolean>`. By default, the application writes an error message to stderr. Return `True</api/language/true>` to suppress output to stderr.

## Notes

A Service application is a special type of `ConsoleApplication</api/console/consoleapplication>` that is designed to run without any interface and even if are no users logged in. A Service application should not require any user interaction since it's possible that no user is logged in while your application is running. Typical examples of service applications are FTP servers, HTTP servers, and other types of servers that have no user interface.

Console applications rely on the `Print</api/console/print>` and `Input</api/console/input>` commands for communicating with the user. Services behave much the same (depending on how the service is installed, and on what operating system). For example, if your service is run as a daemon on macOS or Linux using the inet.d scripts, then `Print</api/console/print>` and `Input</api/console/input>` will actually correspond to a socket that the system has already attached for you. This means that the Write method of the `StandardOutputStream</api/console/standardoutputstream>` class will actually behave just like a socket and the Read method of the `StandardInputStream</api/console/standardinputstream>` class will as well.

It is worth noting that this behavior is not guaranteed for all operating systems. If you plan on deploying your service on multiple OS's, it is best to use a `TCPSocket</api/networking/tcpsocket>` directly instead of relying on standard input and output being hooked up to a socket for you.

To create a service application, you must first create a regular console application. Choose File \> New Project and choose the Console Application item. A console application has a single project item called App whose super class is `ConsoleApplication</api/console/consoleapplication>`. Change `App's</api/language/app>` super to <span class="title-ref">ServiceApplication</span>.

The <span class="title-ref">ServiceApplication</span> class is a subclass of `ConsoleApplication</api/console/consoleapplication>` class, so all the `ConsoleApplication</api/console/consoleapplication>` events and methods are available. In addition to the `ConsoleApplication</api/console/consoleapplication>`'s events, there are three new events for a <span class="title-ref">ServiceApplication</span>. Some of these events will be fired only on operating systems that support them-and the only OS that supports them currently is Windows.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Installing a service application on windows

If you use an installer, check if it can create the service for you automatically. If you would rather do it by hand, the Windows command sc (service controller) is used to install services.

``` plain
sc create RSWebSvc type= own start= auto binpath= c:\Path\To\Exe\WebApp.exe
```

Do not leave out the spaces after each = sign in the above command.

After the service is installed, you will see it in the Services Manager where you can start, pause or stop it. The following can also be used to start the service:

``` plain
sc start RSWebSvc
```

<div class="note">

<div class="title">

Note

</div>

The `sc` command should be run with Administrator privileges in order to function correctly.

</div>

## Compatibility

|                       |              |
|-----------------------|--------------|
| **Project Types**     | Console, Web |
| **Operating Systems** | Windows      |

<div class="seealso">

`ConsoleApplication</api/console/consoleapplication>` parent class; `StandardInputStream</api/console/standardinputstream>`, `StandardOutputStream</api/console/standardoutputstream>` classes; `Input</api/console/input>`, `Print</api/console/print>`, `StdErr</api/console/stderr>`, `StdIn</api/console/stdin>`, `StdOut</api/console/stdout>` methods; `TargetConsole</api/compiler_directives/targetconsole>` constant

</div>
