Windows Services installation, uninstallation

Source: Internet
Author: User

1. New Project Select Windows Service

2. Add installation program

3. Modify the Installation code

        ServiceProcessInstaller Processinstall;        ServiceInstaller ServiceInstall;        Public ProjectInstaller ()        {            This.processinstall = new ServiceProcessInstaller ();            This.serviceinstall = new ServiceInstaller ();            Processinstall.account = Serviceaccount.localsystem;            This.serviceInstall.ServiceName = "Abc_taskservice";            This.serviceInstall.Description = "Abc_description";            This. Installers.add (This.serviceinstall);            This. Installers.add (This.processinstall);        }

  

4. Rebuild the project

5. New BAT file (install service. bat)

@ECHO Offrem The following directory is for. Net1.1set Dotnetfx=%systemroot%\microsoft.net\framework\v4.0.30319set path=%path%;%d OTNETFX%CDcd "G:\WindowsServiceTest\WindowsServiceTest\bin\Debug"Echo is installing the test service echo--------------------- ------------------------------installutil/i WindowsServiceTest.exesc config "Abc_taskservice" start= AutoNet Start "Abc_taskservice"echo---------------------------------------------------Pause

Attention:

1. The CD "G:\WindowsServiceTest\WindowsServiceTest\bin\Debug" path is the path of the project

2. installutil/i WindowsServiceTest.exe where windowsservicetest the name of the file that was rebuilt for the project

3. sc config "abc_taskservice" start= Auto where Abc_taskservice is the name of the service from the third step

4, the bat file must be executed at the Administrator: command prompt operation otherwise will be wrong (unable to open the Count machine.) on the Service Control manager, Access denied, etc.

6. New BAT file (uninstall service. bat)

@ECHO Offrem The following directory is for. Net1.1set Dotnetfx=%systemroot%\microsoft.net\framework\v4.0.30319set path=%path%;%d OTNETFX%CDCD "G:\WindowsServiceTest\WindowsServiceTest\bin\Debug" Echo is uninstalling the test service echo------------------------------ ---------------------installutil/u Windowsservicetest.exeecho-------------------------------------------------- -pause

  

Installation Services. Bat Download

Uninstall the service. Bat download

Windows Services installation, uninstallation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.