Creating a Windows Service Installer

To register your Windows service with the operating system, you need to add an installer to your project that contains the necessary code to allow you to register the service. To do so, right-click the Windows service designer surface and select Add Installer




Once you do this, you can see two components have been added to a new designer surface
representing the installer. The first component (named serviceProcessInstaller1 by default) represents
an item that can install a new Windows service on the target machine. Select this item on the designer
and use the Properties window to set the Account property to LocalSystem



The second component (named serviceInstaller1) represents a type that will install your particular Windows service. Again, use the Properties window to change the ServiceName property toMathService (as you might have guessed, this represents the friendly display name of the registered
Windows service), set the StartType property to Automatic, and add a friendly description of your
Windows service using the Description property



Installing the Windows Service
A Windows service can be installed on the host machine using a traditional setup program (such as an
*.msi installer) or via the installutil.exe command-line tool. Using a Visual Studio 2010 command
prompt, change into the \bin\Debug folder of your MathWindowsServiceHost project. Now, enter the
following command:
installutil MathWindowsServiceHost.exe
Assuming the installation succeeded, you can now open the Services applet located under the
Administrative Tools folder of your Control Panel. You should see the friendly name of your Windows
service listed alphabetically. Once you locate it, make sure you start the service on your local machine
using the Start link