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
Right click on the Service1.cs file and select View Designer from the
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.
Click on the serviceProcessInstaller1 icon on the designer and view its
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.
Now click on the serviceInstaller1 icon on the designer and view its
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.
Recompile the project again.
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.
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
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.