2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/sc/sc.c
5 * PURPOSE: parse command line
6 * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>
20 DWORD ErrorCode
= GetLastError();
21 if (ErrorCode
!= ERROR_SUCCESS
)
23 RetVal
= FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
24 FORMAT_MESSAGE_FROM_SYSTEM
|
25 FORMAT_MESSAGE_IGNORE_INSERTS
,
28 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), /* Default language */
35 _tprintf(_T("%s"), (LPTSTR
)lpMsgBuf
);
43 ScControl(LPCTSTR Server
, // remote machine name
44 LPCTSTR Command
, // sc command
45 LPCTSTR
*ServiceArgs
, // any options
46 DWORD ArgCount
) // argument counter
48 LPCTSTR ServiceName
= NULL
;
52 _tprintf(_T("Remote service control is not yet implemented\n"));
56 if (!lstrcmpi(Command
, _T("query")))
62 else if (!lstrcmpi(Command
, _T("queryex")))
68 else if (!lstrcmpi(Command
, _T("start")))
72 ServiceName
= *ServiceArgs
++;
82 else if (!lstrcmpi(Command
, _T("pause")))
86 ServiceName
= *ServiceArgs
++;
89 Control(SERVICE_CONTROL_PAUSE
,
97 else if (!lstrcmpi(Command
, _T("interrogate")))
101 ServiceName
= *ServiceArgs
++;
104 Control(SERVICE_CONTROL_INTERROGATE
,
112 else if (!lstrcmpi(Command
, _T("stop")))
116 ServiceName
= *ServiceArgs
++;
119 Control(SERVICE_CONTROL_STOP
,
127 else if (!lstrcmpi(Command
, _T("continue")))
131 ServiceName
= *ServiceArgs
++;
134 Control(SERVICE_CONTROL_CONTINUE
,
142 else if (!lstrcmpi(Command
, _T("delete")))
146 ServiceName
= *ServiceArgs
++;
154 else if (!lstrcmpi(Command
, _T("create")))
156 Create(ServiceArgs
, ArgCount
);
158 else if (!lstrcmpi(Command
, _T("control")))
164 ServiceName
= *ServiceArgs
++;
167 CtlValue
= _ttoi(ServiceArgs
[0]);
171 if ((CtlValue
>= 128) && (CtlValue
<= 255))
182 else if (!lstrcmpi(Command
, _T("sdshow")))
186 ServiceName
= *ServiceArgs
++;
194 else if (!lstrcmpi(Command
, _T("sdset")))
196 LPCTSTR SecurityDescriptor
;
200 ServiceName
= *ServiceArgs
++;
203 SecurityDescriptor
= *ServiceArgs
++;
206 SdSet(ServiceName
, SecurityDescriptor
);
211 else if (!lstrcmpi(Command
, _T("qc")))
215 ServiceName
= *ServiceArgs
++;
218 QueryConfig(ServiceName
);
223 else if (!lstrcmpi(Command
, _T("qdescription")))
227 ServiceName
= *ServiceArgs
++;
230 QueryDescription(ServiceName
);
233 QueryDescriptionUsage();
235 else if (!lstrcmpi(Command
, _T("qfailure")))
239 ServiceName
= *ServiceArgs
++;
242 QueryFailure(ServiceName
);
255 int _tmain(int argc
, LPCTSTR argv
[])
257 LPCTSTR Server
= NULL
; // remote machine
258 LPCTSTR Command
= NULL
; // sc command
259 LPCTSTR
*Args
= NULL
; // Any remaining args
267 /* get server name */
268 if ((argv
[1][0] == '\\') && (argv
[1][1] == '\\'))
281 return ScControl(Server
,
292 return ScControl(Server
,