How to install and uninstall window service in .Net Framework

Dung Do Tien Mar 22 2021 228

I created a window service in C# .Net Framework 4.5. After building the project, I don't know how to install & uninstall it on my VPS server(Window Server 8).

This is my bin folder:

How to install and uninstall window service in .Net Framework

Thanks for any suggestions.

Have 2 answer(s) found.
  • T

    Thủy Lê Mar 22 2021

    You can use sc.exe tool to help install and uninstall your window server as below:

    - Open cmd, don't forget run as administrator. And type:

     sc.exe create [SERVICE NAME] binpath= "SERVICE FULL PATH"

    In that: 

    [Service Name] : Name of service will install, it does not allow space.

    SERVICE FULL PATH gives the service exe file full path(absolute path to .exe file).

    For example:

    sc.exe create CRM.TestService binPath= "F:\Project\DemoWindowService\bin\Debug\CRM.FinnalProject.AutoUpdateProductexe"

    - To Uninstall you can use command as below:

     sc.exe delete SERVICE NAME

    For example:

    sc.exe delete CRM.TestSerice
    
  • K

    Kingtub Kakkak Mar 22 2021

    To install service:

    Open CMD as run as administrator
    Type cd %systemroot%\Microsoft.NET\Framework\v4.0.30319\    -> and press enter
    Note: you may need to change the framework version based on VS on your computer.
    Type installutil SERVICE PATH
    For example:

    installutil F:\Project\DemoWs\bin\Debug\CRM.FinnalProject.AutoUpdateProduct.exe

    To uninstall service:

    Open CMD as run as administrator
    Type cd %systemroot%\Microsoft.NET\Framework\v4.0.30319\    -> and press enter
    Note: you may need to change the framework version based on VS you have
    Type installutil -u SERVICE PATH
    For example:

    installutil -u F:\Project\DemoWs\bin\Debug\CRM.FinnalProject.AutoUpdateProduct.exe
    
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close