Shut MSVC warnings up
[reactos.git] / reactos / subsys / system / sc / usage.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS SC utility
4 * FILE: subsys/system/sc/usage.c
5 * PURPOSE: control ReactOS services
6 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
7 * REVISIONS:
8 * Ged Murphy 20/10/05 Created
9 *
10 */
11 #include <conio.h>
12 #include "sc.h"
13
14 INT 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, 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 return 0;
95 }
96
97
98 INT StartUsage(VOID)
99 {
100 _tprintf(_T("DESCRIPTION:\n")
101 _T(" Starts a service running.\n")
102 _T("USAGE:\n")
103 _T(" sc <server> start [service name] <arg1> <arg2> ...\n"));
104
105 return 0;
106 }
107
108
109 INT PauseUsage(VOID)
110 {
111 _tprintf(_T("DESCRIPTION:\n")
112 _T(" Sends a PAUSE control request to a service.\n")
113 _T("USAGE:\n")
114 _T(" sc <server> pause [service name]\n"));
115
116 return 0;
117 }
118
119 INT InterrogateUsage(VOID)
120 {
121 _tprintf(_T("DESCRIPTION:\n")
122 _T(" Sends an INTERROGATE control request to a service.\n")
123 _T("USAGE:\n")
124 _T(" sc <server> interrogate [service name]\n"));
125
126 return 0;
127 }
128
129
130 INT StopUsage(VOID)
131 {
132 _tprintf(_T("DESCRIPTION:\n")
133 _T(" Sends an STOP control request to a service.\n")
134 _T("USAGE:\n")
135 _T(" sc <server> stop [service name]\n"));
136
137 return 0;
138 }
139
140 INT ContinueUsage(VOID)
141 {
142 _tprintf(_T("DESCRIPTION:\n")
143 _T(" Sends an CONTINUE control request to a service.\n")
144 _T("USAGE:\n")
145 _T(" sc <server> continue [service name]\n"));
146
147 return 0;
148 }
149
150
151 INT ConfigUsage(VOID)
152 {
153 _tprintf(_T("not yet implemented\n"));
154
155 return 0;
156 }
157
158
159 INT DescriptionUsage(VOID)
160 {
161 _tprintf(_T("DESCRIPTION:\n")
162 _T(" Sets the description string for a service.\n")
163 _T("USAGE:\n")
164 _T(" sc <server> description [service name]\n"));
165
166 return 0;
167 }
168
169 INT DeleteUsage(VOID)
170 {
171 _tprintf(_T("DESCRIPTION:\n")
172 _T(" Deletes a service entry from the registry.\n")
173 _T(" If the service is running, or another process has an\n")
174 _T(" open handle to the service, the service is simply marked\n")
175 _T(" for deletion.\n")
176 _T("USAGE:\n")
177 _T(" sc <server> delete [service name]\n"));
178
179 return 0;
180 }
181
182 INT CreateUsage(VOID)
183 {
184 _tprintf(_T("Creates a service entry in the registry and Service Database.\n")
185 _T("SYNTAX:\n")
186 _T("sc create [service name] [binPath= ] <option1> <option2>...\n")
187 _T("CREATE OPTIONS:\n")
188 _T("NOTE: The option name includes the equal sign.\n")
189 _T(" type= <own|share|interact|kernel|filesys|rec>\n")
190 _T(" (default = own)\n")
191 _T(" start= <boot|system|auto|demand|disabled>\n")
192 _T(" (default = demand)\n")
193 _T(" error= <normal|severe|critical|ignore>\n")
194 _T(" (default = normal)\n")
195 _T(" binPath= <BinaryPathName>\n")
196 _T(" group= <LoadOrderGroup>\n")
197 _T(" tag= <yes|no>\n")
198 _T(" depend= <Dependencies(separated by / (forward slash))>\n")
199 _T(" obj= <AccountName|ObjectName>\n")
200 _T(" (default = LocalSystem)\n")
201 _T(" DisplayName= <display name>\n")
202 _T(" password= <password>\n"));
203
204 return 0;
205 }