How to Developed Window service:
- Open VS.NET and then at the File menu click on New, Project. From the New Project Dialog Box, choose the Windows service template and name it WindowsServiceDemo
- Go to design view for Service1.
- Click the background of the designer to select the service itself, rather than any of its contents.
- Right click on form then In the Properties window, click the Add Installer link by default, two installers is added to your project. The component is named ProjectInstaller.
- ProjectInstaller consists ServiceInstaller1 and ServiceProcessInstaller1
- Access design view for ProjectInstaller, and click ServiceInstaller1.
- In the Properties window, set the ServiceName property to WindowsServiceDemo and Set the StartType property to Automatic.
- Access design view for ProjectInstaller, and click ServiceProcessInstaller1.
- In the Properties window, set account property Local System
- Implement Code.
- Create Setup.
- Add new Project in same Solution and Select Setup and deployment then setup project and name it WindowsServiceSetup
- In Solution Explorer, right-click WindowsServiceSetup, point to Add, then choose Project Output. The Add Project Output Group dialog box appears.
- WindowsServiceDemo is selected in the Project box.
- From the list box, select Primary Output, and click OK.
- In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears.
- In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The Select Item in Project dialog box appears.
- Double-click the application folder in the list box to open it, select primary output from WindowsServiceDemo (Active), and click OK. The primary output is added to all four nodes of the custom actions — Install, Commit, Rollback, and Uninstall.
- Build the setup project to create Setup.