Use CMD in Windows to implement custom service installation and uninstallation

Source: Internet
Author: User

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

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.