author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 05 Aug 2015 23:55:34 +0300 | |
changeset 1729 | 22ffd80639c0 |
parent 1673 | ed7fa7e54aaa |
child 1905 | fba288d59662 |
permissions | -rw-r--r-- |
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
.. -*- coding: utf-8; -*- |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
.. include:: HEADER.rst |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
================== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
Windows service. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
================== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
.. contents:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
|
1673
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
9 |
About Windows services. |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
10 |
======================= |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
11 |
|
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
12 |
http://www.coretechnologies.com/WindowsServices/FAQ.html |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
13 |
Windows Services Frequently Asked Questions (FAQ). |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
14 |
|
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
List services. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
============== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
17 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
18 |
List of all running services:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
20 |
cmd> net start |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
21 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
22 |
List of all services:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
24 |
cmd> sc query |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
25 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
26 |
List of specific service:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
27 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
cmd> sc query NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
|
1671 | 30 |
GUI tool:: |
31 |
||
32 |
cmd> services.msc |
|
33 |
||
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
Start/stop service. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
=================== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
38 |
cmd> net start NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
cmd> sc start NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
40 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
41 |
cmd> net stop NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
42 |
cmd> sc stop NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
43 |
|
1671 | 44 |
cmd> services.msc |
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
45 |
|
1671 | 46 |
Create service. |
47 |
=============== |
|
48 |
||
49 |
In order to create service from any executable use ``srvany.exe`` from Windows |
|
50 |
Resource Kits 2003 (take attention to spaces after ``=``):: |
|
51 |
||
52 |
cmd> sc create NAME binPath= "c:\Program Files\Windows Resource Kits\Tools\srvany.exe" ^ |
|
53 |
type= own start= auto error= normal DisplayName= "NAME for services.msc" |
|
54 |
||
55 |
Then pass what ``srvany.exe`` wrapper to do:: |
|
56 |
||
57 |
cmd> reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME\Parameters" ^ |
|
58 |
/v "Application" ^ |
|
59 |
/d "\"c:\Program Files\Java\jre7\bin\java.exe\" -cp c:\home\devel\service Main" |
|
60 |
||
61 |
Above you see quoting syntax for spaces and quotes. Next start service with:: |
|
62 |
||
63 |
cmd> sc start NAME |
|
64 |
||
65 |
If you make error recheck your settings with:: |
|
66 |
||
67 |
cmd> reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME" /s |
|
68 |
||
69 |
Or remove service and make steps again:: |
|
70 |
||
71 |
cmd> sc delete NAME |
|
72 |
||
73 |
Visit GUI ``services.msc`` and check with ``procexp.exe`` that service actually |
|
74 |
do job. |
|
75 |
||
76 |
http://www.microsoft.com/en-us/download/confirmation.aspx?id=17657 |
|
77 |
Windows Server 2003 Resource Kit Tools download. |
|
78 |
http://stackoverflow.com/questions/3663331/creating-a-service-with-sc-exe-how-to-pass-in-context-parameters |
|
79 |
How to pass parameters to sc.exe runnable. |
|
1673
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
80 |
https://support.microsoft.com/KB/137890 |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
81 |
How To Create a User-Defined Service (with Srvany.exe). |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
82 |
http://technet.microsoft.com/en-us/library/cc990289.aspx |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
83 |
Sc create help. |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
84 |
http://support.microsoft.com/kb/251192 |
ed7fa7e54aaa
About Windows services.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1672
diff
changeset
|
85 |
How to create a Windows service by using Sc.exe |
1671 | 86 |
|
87 |
Delete service. |
|
88 |
=============== |
|
89 |
:: |
|
90 |
||
91 |
cmd> sc delete NAME |
|
92 |
||
1672 | 93 |
Service wrapper. |
94 |
================ |
|
95 |
||
96 |
http://en.wikipedia.org/wiki/Service_wrapper |
|
97 |
Service wrapper |
|
98 |
http://nssm.cc/ |
|
99 |
NSSM - the Non-Sucking Service Manager |
|
100 |
http://sourceforge.net/projects/yajsw/ |
|
101 |
Yet Another Java Service Wrapper |
|
102 |
https://github.com/kohsuke/winsw/ |
|
103 |
A wrapper executable that can be used to host any executable as an Windows |
|
104 |
service |
|
105 |
http://code.google.com/p/simple-service-wrapper/ |
|
106 |
Simple Windows Service Wrapper |
|
107 |