How to Create a Windows Service

In this tutorial, I will outline the the steps I took to create a Windows Service using the Windows Server Resource Kit. The "ProxyServer" referenced in this article is a lightweight, command line app. Please substitute "ProxyServer" with the name of your application.

To create a Windows NT user-defined service, perform the following steps:

  1. Download and Install the Windows Server Resource Kit
  2. At a MS-DOS command prompt (running CMD.EXE), type the following command:
    "C:\Program Files (x86)\Windows Resource Kits\Tools\INSTSRV.EXE" ProxyServer 
    "C:\Program Files (x86)\Windows Resource Kits\Tools\SRVANY.EXE"
    Where "C:\Program Files (x86)\Windows Resource Kits\Tools\" is the drive and directory of the Windows NT Resource Kit and "ProxyServer" is the name of the service you are creating. If all goes well, you should see the following message:
    The service was successfully added!
    Make sure that you go into the Control Panel and use
    the Services applet to change the Account Name and
    Password that this newly installed service will use
    for its Security Context.
  3. Next, you will need to create a registry key for your new service. Run Registry Editor (Regedt32.exe) and locate the following subkey:
  4. Create a new key called Parameters.
  5. In the Parameters key/folder, create a new key called Application.
  6. Edit the value for the Application key by entering the fully qualified path to the executable, along with any command line arguments. Example:
    "C:\Program Files (x86)\Java\jre6\bin\java.exe" -Xmx1024M -jar D:\ProxyServer.jar 8181
    Here's a screenshot of what the registry should look like after your edits.

  7. At this point you should be able to go to the services tab in Computer Management and configure your service.