In the project, there are times when we need to customize some service to handle some business logic at timed time, which involves installing and uninstalling the service problem, how to install it? We will organize some solutions for your reference:
Programme one:
1. Run--〉cmd: Open cmd Command box
2. Locate the InstallUtil.exe location in the command line
InstallUtil.exe The default installation location is in C:\Windows\Microsoft.NET\Framework\v4.0.30319, so you need to navigate to that location in CMD via CD (CD c:/windows/ microsoft.net/framework/v4.0.30319)
It is particularly important to note that the C:\Windows\Microsoft.NET\Framework\v4.0.30319 v4.0.30319 is the version of our Framework.
3. Operation Command:
1). Install the service command: Enter the following command at the command line:
InstallUtil.exe Path/winservicename.exe
Where path indicates where the ServiceName.exe is located, enter
2). Start the service command
net start ServiceName
ServiceName is the name of the real Service (Servicebase.servicename), which may or may not be the same as the name of the. exe. If not clear, to the installed services to find your service, right-click on the property to see the service name
3). Stop Service Command
net stop ServiceName
4). Uninstall Service Command: Enter the following command at the command line:
Installutil.exe/u Path/winservicename.exe
Where path indicates where the ServiceName.exe is located, enter
Scenario Two:
1. Use the command to switch to the folder under your service;
2. Use Services.exe install enter;
3. Use Services.exe Uninstall uninstall service, enter;
These two scenarios are related to the version of the framework, I use the first scenario in the project, although the prompt is successful, but in the service (local) can not find the installed service, and finally use the second scenario after the normal, recommend the use of the second scenario!
Hope that the above content to you some help, thank you!
Use CMD in Windows to implement custom service installation and uninstallation