How to register an ordinary exe server program as a windows Service

Source: Internet
Author: User

Although most programs are written under freebsd and linux. However, we have encountered a problem in windows recently, that is, how to enable a server written in Go language to automatically start when the server is started on windows.

Therefore, it cannot be set to start in run. It is more reliable to make the server into a window. However, at the time of design, the program was run in linux. Later, it was migrated to windows for some reason, and the window service was not considered during writing.

The basic steps are as follows:

 

1. Prepare instsrv.exe srvany.exe. These two files are downloaded from the attachment.

Instsrv.exe is used to register a service. The usage is as follows:

Usage: instsrv <service name> <exe location> to install a service,

Or: instsrv <service name> remove to remove a service

Of course, the SC command can also be used to operate the service.

2. Register a srvany.exe Service

Instsrv MyService location/to/srvany.exe

3. Modify the Registry: Put the executable file of the real service in the registry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ services \ MyService \ Parameters]

"Application" = "D: \ go \ tester \ src \ signalserver \ server \ signalserver.exe"

"AppDirectory" = "D: \ go \ tester \ src \ signalserver \ server"

"AppParameters" = ""

You can also manually modify the information in the registry or save the information as exe.

MyService is the service name.

Application Service Executable File Path

Directory of AppDirectory Service Execution

AppParameters parameter information, which can be blank

 

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.