[ About | Licence | Contacts ]
Written by Oleksandr Gavenko (AKA gavenkoa), compiled on 2024-04-01 from rev 052223c22317.

Windows service.

About Windows services.

Windows Services Frequently Asked Questions (FAQ).

List services.

List of all running services:

cmd> net start
cmd> tasklist /svc

List of all services:

cmd> sc query

List of specific service:

cmd> sc query NAME

GUI tool:

cmd> services.msc

Start/stop service.

cmd> net start NAME
cmd> sc start NAME

cmd> net stop NAME
cmd> sc stop NAME

cmd> services.msc

Create service.

In order to create service from any executable use srvany.exe from Windows Resource Kits 2003 (take attention to spaces after =):

cmd> sc create NAME binPath= "c:\Program Files\Windows Resource Kits\Tools\srvany.exe" ^
     type= own start= auto error= normal DisplayName= "NAME for services.msc"

Then pass what srvany.exe wrapper to do:

cmd> reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME\Parameters" ^
   /v "Application" ^
   /d "\"c:\Program Files\Java\jre7\bin\java.exe\" -cp c:\home\devel\service Main"

Above you see quoting syntax for spaces and quotes. Next start service with:

cmd> sc start NAME

If you make error recheck your settings with:

cmd> reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME" /s

Or remove service and make steps again:

cmd> sc delete NAME

Visit GUI services.msc and check with procexp.exe that service actually do job.

Windows Server 2003 Resource Kit Tools download.
How to pass parameters to sc.exe runnable.
How To Create a User-Defined Service (with Srvany.exe).
Sc create help.
How to create a Windows service by using Sc.exe

Delete service.

cmd> sc delete NAME

Service wrapper.

Service wrapper
NSSM - the Non-Sucking Service Manager
Yet Another Java Service Wrapper
A wrapper executable that can be used to host any executable as an Windows service
Simple Windows Service Wrapper