<p>To create a Windows Service from an executable, vous pouvez utiliser <code>sc.exe</code>:</p>
<pre><code class="lang-auto">sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"
</code></pre>
<p>You must have quotation marks around the actual <code>exe</code> path, and a space after the <code>binPath=</code>.</p>
<p><a href="http://support.microsoft.com/kb/251192">More information on the <code>sc</code> command can be found in Microsoft KB251192</a>.</p>
<p>Notez que it will not work for just any executable: the executable must be a Windows Service (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms685138(v=vs.85).aspx">i.e. implement ServiceMain</a>). When registering a non-service executable as a service, you’ll get the following error upon trying to start the service:</p>
<p>Error 1053: The service did not respond to the start or control request in a timely fashion.</p>
<p>Il y a tools that can create a Windows Service from arbitrary, non-service executables, see the other answers for examples of such tools.</p>