(Copied from the 101 .net samples
Create the Windows Service. Simply create a new Windows Service project in Visual Basic. You are provided with a overrides for the OnStart and OnStop methods. Add code to these methods, and implement any additional overrides (such as for the OnContinue and OnPause methods). You must also set the proper parameter. For instance, the CanPauseAndContinue must be set to True for the service to be able to accept those events.
Add an Installer. You can add an installer by right clicking on the design palette of the windows service, and selecting "Add Installer". The installer is required to make the proper changes in the registry, and to get the service hooked into the right event sources. You can then configure the installer. In your ServiceProcessInstaller, you need to determine the account that will start the service. Popular choices are LocalSystem and User. In the WindowsServiceInstaller, you need to specifiy how the service will start. Choose Manual if the service should be started by a user action. Select Automatic if the service should be run on startup.
Create a deployment. Windows Services can be deployed by using the InstallUtil.exe utility that comes with the .NET Framework. However, a more convenient method is to use a deployment project to create an MSI file. This is only slightly tricky for a Windows Service. First, add a deployment project to the solution containing the service project. Then create a Custom Action for the primary output of the Windows Service project. (To do this, right-click on the deployment project name and select View -> Custom Actions. Then right click on the Custom Actions and select Add Custom Action. When the dialog box opens double click the Application folder and select the primary output from your Windows Service project. It will add this custom action to all four installer actions: Install, Commit, Rollback and Uninstall.) You can now Build your solution, and the resulting MSI file will install the Windows Service
The gap between theory and practice is not as wide in theory as it is in practice.