How To Create a User-Defined Service

The following did not work with FullSync, it appear to start but not run properly

You will need to install the Window 2003 rktools.exe

The Windows NT Resource Kit provides two utilities that allow you to create a Windows NT user-defined service for Windows NT applications and some 16-bit applications (but not for batch files).

Instrsrv.exe installs and removes system services from Windows NT and Srvany.exe allows any Windows NT application to run as a service.

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

  1. At a MS-DOS command prompt(running CMD.EXE), type the following command:path\INSTSRV.EXE My Service path\SRVANY.EXEwhere path is the drive and directory of the Windows NT Resource Kit (i.e., C:\RESKIT) and My Serviceis the name of the service you are creating.Example:
    C:\Program Files\Resource Kit\Instsrv.exe Notepad C:\Program Files\Resource Kit\Srvany.exe

    NOTE:To verify that the service was created correctly, check the registry to verify that the ImagePath value under

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name

    is set to point to SRVANY.EXE. If this is not set correctly, the service will stop shortly after it starts and return an Event ID 7000 "The service name failed to start."

    WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

    For information about how to edit the registry, view the "Changing Keys And Values" online Help topic or the "Add and Delete Information in the Registry" and "Edit Registry Data" online Help topics in Registry Editor.

    NOTE: You should back up the registry before you edit it.

  2. Run Registry Editor (Regedt32.exe)and locate the following subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<My Service>
  3. From the Edit menu, click Add Key. Type the following and click OK:Key Name: Parameters
    Class : <leave blank>
  4. Select the Parameters key.
  5. From the Edit menu, click Add Value. Type the following and click OK:Value Name: Application
    Data Type : REG_SZ
    String : <path>\<application.ext>where <path>\<application.ext> is the drive and full path to the application executable including the extension (i.e., C:\WinNT\Notepad.exe)
  6. Close Registry Editor.

By default, a newly created service it configured to run Automatically when the system is restarted. To change this setting to Manual, run the Services applet from Control Panel and change the Startup value to Manual. A service set to Manual can be started in one of several ways:

- From the Services applet in Control Panel- From a MS-DOS command prompt, type the following:NET START <My Service>- Use the Sc.exe utility from the Resource Kit. Type the following from a MS-DOS command prompt:<path>\Sc.exe start <My Service>

where <path> is the drive and directory of the Windows NT Resource Kit (i.e., C:\Reskit).

How to remove a service:

Recently, I was trying to delete a windows service. Normally it should not be necessary to manually delete a service. Uninstalling an application should remove its associated service (if any).

However, I installed some beta products and a service created by one of the applications was not removed automatically. Its very easy to remove a service from registry if you know the right path. Here is how I did that:

1. Run Regedit or Regedt32

2. Find the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"

3. Look for the service there and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).

alternatively, you can also use command prompt and delete a service using following command:

sc delete < SERVICE name>

or to create, simply type
sc create <SERVICE name>

Update:
If you have space in the file path you need to use quotation marks ("). For example:
sc create "MySQL" binpath= "C:\Archivos de programa\MySQL\MySQL Server 5.1\bin\mysqld.exe"

Thanks to Maya.

NOTE: You may have to reboot the system to get the list updated in service manager.