445863df49a99171f1d05bdc61a6f5f4e5eb6c09
[reactos.git] / reactos / base / applications / sc / usage.c
1 /*
2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/sc/usage.c
5 * PURPOSE: display usage info
6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
7 *
8 */
9
10 #include "sc.h"
11
12 #include <conio.h>
13
14 VOID MainUsage(VOID)
15 {
16 INT c;
17
18 _tprintf(_T("DESCRIPTION:\n")
19 _T("\tSC is a command line program used for communicating with\n")
20 _T("\tthe Service Control Manager and its services.\n")
21 _T("USAGE:\n")
22 _T("\tsc <server> [command] [service name] <option1> <option2>...\n")
23
24 _T("\tThe optional parameter <server> has the form \"\\ServerName\"\n")
25 _T("\tFurther help on commands can be obtained by typing: \"sc [command]\"\n")
26 _T("\tService Commands:\n")
27 _T("\t query : Queries the status for a service, or\n")
28 _T("\t enumerates the status for types of services.\n")
29 _T("\t queryex : Queries the extended status for a service, or\n")
30 _T("\t enumerates the status for types of services.\n")
31 _T("\t start : Starts a service.\n")
32 _T("\t pause : Sends a PAUSE control request to a service.\n")
33 _T("\t interrogate : Sends a INTERROGATE control request to a service.\n")
34 _T("\t continue : Sends a CONTINUE control request to a service.\n")
35 _T("\t stop : Sends a STOP request to a service.\n")
36 _T("\t config : Changes the configuration of a service (persistant).\n")
37 _T("\t description : Changes the description of a service.\n")
38 _T("\t failure : Changes the actions taken by a service upon failure.\n")
39 _T("\t qc : Queries the configuration information for a service.\n")
40 _T("\t qdescription : Queries the description for a service.\n")
41 _T("\t qfailure : Queries the actions taken by a service upon failure.\n")
42 _T("\t delete : Deletes a service (from the registry).\n")
43 _T("\t create : Creates a service (adds it to the registry).\n")
44 _T("\t control : Sends a control to a service.\n")
45 _T("\t sdshow : Displays a service's security descriptor.\n")
46 _T("\t sdset : Sets a service's security descriptor.\n")
47 _T("\t GetDisplayName : Gets the DisplayName for a service.\n")
48 _T("\t GetKeyName : Gets the ServiceKeyName for a service.\n")
49 _T("\t EnumDepend : Enumerates Service Dependencies.\n"));
50 // "\n")
51 // "\tService Name Independant Commands:\n")
52 // "\t boot : (ok | bad) Indicates whether the last boot should\n")
53 // "\t be saved as the last-known-good boot configuration\n")
54 // "\t Lock : Locks the SCM Database\n")
55 // "\t QueryLock : Queries the LockStatus for the SCM Database\n")
56
57 _tprintf(_T("\nWould you like to see help for the QUERY and QUERYEX commands? [ y | n ]: "));
58 c = _getch(); // _gettch isn't defined in our tchar.h
59 _tprintf(_T("%c\n"), c);
60 if (tolower(c) == 'y')
61 {
62 _tprintf(_T("QUERY and QUERYEX OPTIONS :\n")
63 _T(" If the query command is followed by a service name, the status\n")
64 _T(" for that service is returned. Further options do not apply in\n")
65 _T(" this case. If the query command is followed by nothing or one of\n")
66 _T(" the options listed below, the services are enumerated.\n")
67 _T(" type= Type of services to enumerate (driver, service, interact, all)\n")
68 _T(" (default = service)\n")
69 _T(" state= State of services to enumerate (inactive, all)\n")
70 _T(" (default = active)\n")
71 /*
72 _T(" bufsize= The size (in bytes) of the enumeration buffer\n")
73 _T(" (default = 4096)\n")
74 _T(" ri= The resume index number at which to begin the enumeration\n")
75 _T(" (default = 0)\n")
76 _T(" group= Service group to enumerate\n")
77 _T(" (default = all groups)\n")
78 */
79 _T("SYNTAX EXAMPLES\n")
80 _T("sc query - Enumerates status for active services & drivers\n")
81 _T("sc query messenger - Displays status for the messenger service\n")
82 _T("sc queryex messenger - Displays extended status for the messenger service\n")
83 _T("sc query type= driver - Enumerates only active drivers\n")
84 _T("sc query type= service - Enumerates only Win32 services\n")
85 _T("sc query state= all - Enumerates all services & drivers\n")
86 // _T("sc query bufsize= 50 - Enumerates with a 50 byte buffer.\n")
87 // _T("sc query ri= 14 - Enumerates with resume index = 14\n")
88 // _T("sc queryex group= "" - Enumerates active services not in a group\n")
89 _T("sc query type= service type= interact - Enumerates all interactive services\n")
90 _T("sc query type= driver group= NDIS - Enumerates all NDIS drivers\n"));
91 }
92 }
93
94
95 VOID StartUsage(VOID)
96 {
97 _tprintf(_T("DESCRIPTION:\n")
98 _T(" Starts a service running.\n")
99 _T("USAGE:\n")
100 _T(" sc <server> start [service name] <arg1> <arg2> ...\n"));
101 }
102
103
104 VOID PauseUsage(VOID)
105 {
106 _tprintf(_T("DESCRIPTION:\n")
107 _T(" Sends a PAUSE control request to a service.\n")
108 _T("USAGE:\n")
109 _T(" sc <server> pause [service name]\n"));
110 }
111
112 VOID InterrogateUsage(VOID)
113 {
114 _tprintf(_T("DESCRIPTION:\n")
115 _T(" Sends an INTERROGATE control request to a service.\n")
116 _T("USAGE:\n")
117 _T(" sc <server> interrogate [service name]\n"));
118 }
119
120
121 VOID StopUsage(VOID)
122 {
123 _tprintf(_T("DESCRIPTION:\n")
124 _T(" Sends a STOP control request to a service.\n")
125 _T("USAGE:\n")
126 _T(" sc <server> stop [service name]\n"));
127 }
128
129 VOID ContinueUsage(VOID)
130 {
131 _tprintf(_T("DESCRIPTION:\n")
132 _T(" Sends a CONTINUE control request to a service.\n")
133 _T("USAGE:\n")
134 _T(" sc <server> continue [service name]\n"));
135 }
136
137 VOID DeleteUsage(VOID)
138 {
139 _tprintf(_T("DESCRIPTION:\n")
140 _T(" Deletes a service entry from the registry.\n")
141 _T(" If the service is running, or another process has an\n")
142 _T(" open handle to the service, the service is simply marked\n")
143 _T(" for deletion.\n")
144 _T("USAGE:\n")
145 _T(" sc <server> delete [service name]\n"));
146 }
147
148 VOID CreateUsage(VOID)
149 {
150 _tprintf(_T("Creates a service entry in the registry and Service Database.\n")
151 _T("SYNTAX:\n")
152 _T("sc create [service name] [binPath= ] <option1> <option2>...\n")
153 _T("CREATE OPTIONS:\n")
154 _T("NOTE: The option name includes the equal sign.\n")
155 _T(" type= <own|share|interact|kernel|filesys|rec>\n")
156 _T(" (default = own)\n")
157 _T(" start= <boot|system|auto|demand|disabled>\n")
158 _T(" (default = demand)\n")
159 _T(" error= <normal|severe|critical|ignore>\n")
160 _T(" (default = normal)\n")
161 _T(" binPath= <BinaryPathName>\n")
162 _T(" group= <LoadOrderGroup>\n")
163 _T(" tag= <yes|no>\n")
164 _T(" depend= <Dependencies(separated by / (forward slash))>\n")
165 _T(" obj= <AccountName|ObjectName>\n")
166 _T(" (default = LocalSystem)\n")
167 _T(" DisplayName= <display name>\n")
168 _T(" password= <password>\n"));
169 }
170
171 VOID ControlUsage(VOID)
172 {
173 _tprintf(_T("DESCRIPTION:\n")
174 _T(" Sends a CONTROL control request to a service.\n")
175 _T("USAGE:\n")
176 _T(" sc <server> control [service name] <value>\n"));
177 }
178
179 VOID SdShowUsage(VOID)
180 {
181 _tprintf(_T("DESCRIPTION:\n")
182 _T(" Displays a service's security descriptor in SDDL format.\n")
183 _T("USAGE:\n")
184 _T(" sc <server> sdshow <service name>\n"));
185 }
186
187 VOID SdSetUsage(VOID)
188 {
189 _tprintf(_T("DESCRIPTION:\n")
190 _T(" Sets a service's security descriptor.\n")
191 _T("USAGE:\n")
192 _T(" sc <server> sdset <service name> <SD in SDDL format>\n"));
193 }
194
195 VOID QueryConfigUsage(VOID)
196 {
197 _tprintf(_T("DESCRIPTION:\n")
198 _T(" Queries the configuration information for a service.\n")
199 _T("USAGE:\n")
200 _T(" sc <server> qc [service name] <bufferSize>\n"));
201 }
202
203 VOID QueryDescriptionUsage(VOID)
204 {
205 _tprintf(_T("DESCRIPTION:\n")
206 _T(" Retrieves the description string of a service.\n")
207 _T("USAGE:\n")
208 _T(" sc <server> qdescription [service name] <bufferSize>\n"));
209 }
210
211 VOID QueryFailureUsage(VOID)
212 {
213 _tprintf(_T("DESCRIPTION:\n")
214 _T(" Retrieves the actions performed on service failure.\n")
215 _T("USAGE:\n")
216 _T(" sc <server> qfailure [service name] <bufferSize>\n"));
217 }
218
219 VOID SetDescriptionUsage(VOID)
220 {
221 _tprintf(_T("DESCRIPTION:\n")
222 _T(" Sets the description string of a service.\n")
223 _T("USAGE:\n")
224 _T(" sc <server> description [service name] [description]\n"));
225 }
226
227 VOID SetConfigUsage(VOID)
228 {
229 _tprintf(_T("DESCRIPTION:\n")
230 _T(" Modifies a service entry in the registry and Service Database.\n")
231 _T("USAGE:\n")
232 _T(" sc <server> config [service name] <option1> <option2>...\n")
233 _T("CONFIG OPTIONS:\n")
234 _T(" NOTE: The option name includes the equal sign.\n")
235 _T(" type= <own|share|interact|kernel|filesys|rec>\n")
236 _T(" start= <boot|system|auto|demand|disabled>\n")
237 _T(" error= <normal|severe|critical|ignore>\n")
238 _T(" binPath= <BinaryPathName>\n")
239 _T(" group= <LoadOrderGroup>\n")
240 _T(" tag= <yes|no>\n")
241 _T(" depend= <Dependencies(separated by / (forward slash))>\n")
242 _T(" obj= <AccountName|ObjectName>\n")
243 _T(" DisplayName= <display name>\n")
244 _T(" password= <password>\n"));
245 }
246
247 VOID SetFailureUsage(VOID)
248 {
249 _tprintf(_T("DESCRIPTION:\n")
250 _T(" Changes the actions upon failure.\n")
251 _T("USAGE:\n")
252 _T(" sc <server> failure [service name] <option1> <option2>...\n")
253 _T("\n")
254 _T("OPTIONS:\n")
255 _T(" reset= <Length of period of no failures (in seconds)\n")
256 _T(" after which to reset the failure count to 0 (may be INFINITE)>\n")
257 _T(" (Must be used in conjunction with actions= )\n")
258 _T(" reboot= <Message broadcast before rebooting on failure>\n")
259 _T(" command= <Command line to be run on failure>\n")
260 _T(" actions= <Failure actions and their delay time (in milliseconds),\n")
261 _T(" separated by / (forward slash) -- e.g., run/5000/reboot/800\n")
262 _T(" Valid actions are <run|restart|reboot> >\n")
263 _T(" (Must be used in conjunction with the reset= option)\n"));
264 }
265
266 VOID GetDisplayNameUsage(VOID)
267 {
268 _tprintf(_T("DESCRIPTION:\n")
269 _T(" Gets the display name associated with a particular service.\n")
270 _T("USAGE:\n")
271 _T(" sc <server> GetDisplayName <service key name> <bufsize>\n"));
272 }
273
274 VOID GetKeyNameUsage(VOID)
275 {
276 _tprintf(_T("DESCRIPTION:\n")
277 _T(" Gets the key name associated with a particular service, using the\n")
278 _T(" display name as input.\n")
279 _T("USAGE:\n")
280 _T(" sc <server> GetKeyName <service display name> <bufsize>\n"));
281 }
282
283 VOID EnumDependUsage(VOID)
284 {
285 _tprintf(_T("DESCRIPTION:\n")
286 _T(" Enumerates te Services that are dependent on this one.\n")
287 _T("USAGE:\n")
288 _T(" sc <server> EnumDepend <service display name> <bufsize>\n"));
289 }