author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sat, 10 Feb 2018 01:49:07 +0200 | |
changeset 2230 | 9e6ad6607a9e |
parent 2228 | 837f1337c59b |
child 2247 | 91816f9ab872 |
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 |
|
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 |
Windows service. |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
================== |
c7c98a85c749
Windows services from command line.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
.. contents:: |
1905
fba288d59662
Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1673
diff
changeset
|
7 |
:local: |
1670
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 |
|
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
12 |
http://www.coretechnologies.com/WindowsServices/FAQ.html |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
13 |
Windows Services Frequently Asked Questions (FAQ). |
1673
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 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
76 |
http://www.microsoft.com/en-us/download/confirmation.aspx?id=17657 |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
77 |
Windows Server 2003 Resource Kit Tools download. |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
78 |
http://stackoverflow.com/questions/3663331/creating-a-service-with-sc-exe-how-to-pass-in-context-parameters |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
79 |
How to pass parameters to sc.exe runnable. |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
80 |
https://support.microsoft.com/KB/137890 |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
81 |
How To Create a User-Defined Service (with Srvany.exe). |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
82 |
http://technet.microsoft.com/en-us/library/cc990289.aspx |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
83 |
Sc create help. |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
84 |
http://support.microsoft.com/kb/251192 |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
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 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
96 |
http://en.wikipedia.org/wiki/Service_wrapper |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
97 |
Service wrapper |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
98 |
http://nssm.cc/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
99 |
NSSM - the Non-Sucking Service Manager |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
100 |
http://sourceforge.net/projects/yajsw/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
101 |
Yet Another Java Service Wrapper |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
102 |
https://github.com/kohsuke/winsw/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
103 |
A wrapper executable that can be used to host any executable as an Windows |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
104 |
service |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
105 |
http://code.google.com/p/simple-service-wrapper/ |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
106 |
Simple Windows Service Wrapper |
1672 | 107 |