author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Mon, 12 Jan 2015 23:04:42 +0200 | |
changeset 1672 | 7a489de6fb71 |
parent 1671 | ee48c908b156 |
child 1673 | ed7fa7e54aaa |
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 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
List services. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
============== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
List of all running services:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
cmd> net start |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
16 |
List of all services:: |
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 |
cmd> sc query |
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 |
List of specific service:: |
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 |
cmd> sc query NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
23 |
|
1671 | 24 |
GUI tool:: |
25 |
||
26 |
cmd> services.msc |
|
27 |
||
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
28 |
Start/stop service. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
29 |
=================== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
30 |
:: |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
31 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
32 |
cmd> net start NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
33 |
cmd> sc start NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
34 |
|
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
35 |
cmd> net stop NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
36 |
cmd> sc stop NAME |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
37 |
|
1671 | 38 |
cmd> services.msc |
1670
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
39 |
|
1671 | 40 |
Create service. |
41 |
=============== |
|
42 |
||
43 |
In order to create service from any executable use ``srvany.exe`` from Windows |
|
44 |
Resource Kits 2003 (take attention to spaces after ``=``):: |
|
45 |
||
46 |
cmd> sc create NAME binPath= "c:\Program Files\Windows Resource Kits\Tools\srvany.exe" ^ |
|
47 |
type= own start= auto error= normal DisplayName= "NAME for services.msc" |
|
48 |
||
49 |
Then pass what ``srvany.exe`` wrapper to do:: |
|
50 |
||
51 |
cmd> reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME\Parameters" ^ |
|
52 |
/v "Application" ^ |
|
53 |
/d "\"c:\Program Files\Java\jre7\bin\java.exe\" -cp c:\home\devel\service Main" |
|
54 |
||
55 |
Above you see quoting syntax for spaces and quotes. Next start service with:: |
|
56 |
||
57 |
cmd> sc start NAME |
|
58 |
||
59 |
If you make error recheck your settings with:: |
|
60 |
||
61 |
cmd> reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\NAME" /s |
|
62 |
||
63 |
Or remove service and make steps again:: |
|
64 |
||
65 |
cmd> sc delete NAME |
|
66 |
||
67 |
Visit GUI ``services.msc`` and check with ``procexp.exe`` that service actually |
|
68 |
do job. |
|
69 |
||
70 |
http://www.microsoft.com/en-us/download/confirmation.aspx?id=17657 |
|
71 |
Windows Server 2003 Resource Kit Tools download. |
|
72 |
http://stackoverflow.com/questions/3663331/creating-a-service-with-sc-exe-how-to-pass-in-context-parameters |
|
73 |
How to pass parameters to sc.exe runnable. |
|
74 |
||
75 |
Delete service. |
|
76 |
=============== |
|
77 |
:: |
|
78 |
||
79 |
cmd> sc delete NAME |
|
80 |
||
1672 | 81 |
Service wrapper. |
82 |
================ |
|
83 |
||
84 |
http://en.wikipedia.org/wiki/Service_wrapper |
|
85 |
Service wrapper |
|
86 |
http://nssm.cc/ |
|
87 |
NSSM - the Non-Sucking Service Manager |
|
88 |
http://sourceforge.net/projects/yajsw/ |
|
89 |
Yet Another Java Service Wrapper |
|
90 |
https://github.com/kohsuke/winsw/ |
|
91 |
A wrapper executable that can be used to host any executable as an Windows |
|
92 |
service |
|
93 |
http://code.google.com/p/simple-service-wrapper/ |
|
94 |
Simple Windows Service Wrapper |
|
95 |