Lastly, go into the properties for Service1. This will be the actual name that shows up in the "Services" window in the Control Panel, once the service is installed. The last item at hand for completion of this project is to create the windows installer class to allow the project to be compiled as a Windows service.
Now, we need to add two new components to the class- a ServiceInstaller and ServiceProcessInstaller installer. Drag and Drop both onto the file design. If these components are NOT located in the toolbox, simply right-click on the toolbox, and then "Choose Items..
I left the StartType property as Manual. This will enable the service to be run as a local system account. To install the newly created service, you must use the. I have included two batch files within this project- one to install the service, and another to UNinstall it. When the Service starts and stops, it will write a string to a file.
After creating the classes, add three references: System , System. Install , and System. When you do that, your Solution Explorer will look like this:.
Now your project is complete. You can build it. This is your Windows Service. IO; using System. Linq; using System. ServiceProcess; using System. Text; using System. Tasks; using System. Now ; timer. Step 9. Rebuild your application. Right-click on your project or solution and select Rebuild.
Syntax InstallUtil. Type services. You may notice that the Windows service is running. Check Windows Service Output The service will create a text file with the following text in it.
The log folder will be created in your bin folder. Uninstalling a Windows Service If you want to uninstall your service, fire the below command. I hope, you found this tutorial easy to follow and understand. View All.
0コメント