How to install and uninstall window service in .Net Framework
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:
Thanks for any suggestions.
-
T1
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
-
K0
Kingtub Kakkak Mar 22 2021
To install service:
Open CMD as run as administrator
Typecd %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.
Typeinstallutil SERVICE PATH
For example:installutil F:\Project\DemoWs\bin\Debug\CRM.FinnalProject.AutoUpdateProduct.exe
To uninstall service:
Open CMD as run as administrator
Typecd %systemroot%\Microsoft.NET\Framework\v4.0.30319\
-> and press enter
Note: you may need to change the framework version based on VS you have
Typeinstallutil -u SERVICE PATH
For example:installutil -u F:\Project\DemoWs\bin\Debug\CRM.FinnalProject.AutoUpdateProduct.exe
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.