The last step is to install the Windows Service and run it.
There are a few steps you need to follow in order to have the service install
correctly.
1.
Right click on the Service1.cs file and select View Designer from the
pop-up menu.
2.
Right click on the Designer and select Add Installer from the pop-up
menu. A new file will be added to the project called ProjectInstaller.cs.
3.
Click on the serviceProcessInstaller1 icon on the designer and view its
properties.
4.
You can change the Account property to specify the account the Windows
Service should run as when it is executed. Change the Account to LocalService.
5.
Now click on the serviceInstaller1 icon on the designer and view its
properties.
6.
This is where you can define the Description, Display Name, and
StartType. Set the Description to "This service emails reports."
Set the Display Name to "AutomatedReports". Set the StartType to Automatic.
This will ensure the service start when the computer starts.
7.
Recompile the project again.
8.
Now you can install the service. To do this you need to use the command
line utility call InstallUtil.exe that comes with the Visual Studio. To open
the command prompt click on the Start Button and navigate to All ProgramsàMicrosoft Visual Studio 2008àVisual Studio ToolsàVisual Studio 2008 Command Prompt.
9.
Change the directory to the folder that contains the
AutomatedReports.exe file. This will be in the bin\Debug folder under your
project. If you compiled this for release then it will be under the
bin\Release folder.
10. Enter
InstallUtil.exe AutomatedReports.exe and press enter. This will install the
executable as a service and it should appear in the Services located in the
Administration Tools in Windows.