[SC]
[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/system/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 config : Changes the configuration of a service (persistant).\n"
37 // "\t description : Changes the description of a service.\n"
38 // "\t failure : Changes the actions taken by a service upon failure.\n"
39 // "\t qc : Queries the configuration information for a service.\n"
40 // "\t qdescription : Queries the description for a service.\n"
41 // "\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 sdshow : Displays a service's security descriptor.\n")
46 // "\t sdset : Sets a service's security descriptor.\n")
47 // "\t GetDisplayName : Gets the DisplayName for a service.\n")
48 // "\t GetKeyName : Gets the ServiceKeyName for a service.\n")
49 // "\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
138 VOID ConfigUsage(VOID)
139 {
140 _tprintf(_T("not yet implemented\n"));
141 }
142
143
144 VOID DescriptionUsage(VOID)
145 {
146 _tprintf(_T("DESCRIPTION:\n")
147 _T(" Sets the description string for a service.\n")
148 _T("USAGE:\n")
149 _T(" sc <server> description [service name]\n"));
150 }
151
152 VOID DeleteUsage(VOID)
153 {
154 _tprintf(_T("DESCRIPTION:\n")
155 _T(" Deletes a service entry from the registry.\n")
156 _T(" If the service is running, or another process has an\n")
157 _T(" open handle to the service, the service is simply marked\n")
158 _T(" for deletion.\n")
159 _T("USAGE:\n")
160 _T(" sc <server> delete [service name]\n"));
161 }
162
163 VOID CreateUsage(VOID)
164 {
165 _tprintf(_T("Creates a service entry in the registry and Service Database.\n")
166 _T("SYNTAX:\n")
167 _T("sc create [service name] [binPath= ] <option1> <option2>...\n")
168 _T("CREATE OPTIONS:\n")
169 _T("NOTE: The option name includes the equal sign.\n")
170 _T(" type= <own|share|interact|kernel|filesys|rec>\n")
171 _T(" (default = own)\n")
172 _T(" start= <boot|system|auto|demand|disabled>\n")
173 _T(" (default = demand)\n")
174 _T(" error= <normal|severe|critical|ignore>\n")
175 _T(" (default = normal)\n")
176 _T(" binPath= <BinaryPathName>\n")
177 _T(" group= <LoadOrderGroup>\n")
178 _T(" tag= <yes|no>\n")
179 _T(" depend= <Dependencies(separated by / (forward slash))>\n")
180 _T(" obj= <AccountName|ObjectName>\n")
181 _T(" (default = LocalSystem)\n")
182 _T(" DisplayName= <display name>\n")
183 _T(" password= <password>\n"));
184 }
185
186 VOID ControlUsage(VOID)
187 {
188 _tprintf(_T("DESCRIPTION:\n")
189 _T(" Sends a CONTROL control request to a service.\n")
190 _T("USAGE:\n")
191 _T(" sc <server> control [service name] <value>\n"));
192 }