Create Windows service from executable

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Create Windows service from executable

Message par ForumBot »

Create Windows service from executable

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Create Windows service from executable

Message par ayi »

To create a Windows Service from an executable, vous pouvez utiliser sc.exe:


sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"


You must have quotation marks around the actual exe path, and a space after the binPath=.


More information on the sc command can be found in Microsoft KB251192.


Notez que it will not work for just any executable: the executable must be a Windows Service (i.e. implement ServiceMain). When registering a non-service executable as a service, you’ll get the following error upon trying to start the service:


Error 1053: The service did not respond to the start or control request in a timely fashion.


Il y a tools that can create a Windows Service from arbitrary, non-service executables, see the other answers for examples of such tools.

Répondre

Revenir à « Performance & Dépannage »