2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS SC utility
4 * FILE: subsys/system/sc/start.c
5 * PURPOSE: control ReactOS services
6 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
8 * Ged Murphy 20/10/05 Created
14 BOOL
Start(INT ArgCount
, TCHAR
**Args
)
17 SERVICE_STATUS_PROCESS ServiceStatus
;
18 LPCTSTR ServiceName
= *Args
++;
19 LPCTSTR
*ServiceArgs
= (LPCTSTR
*)Args
;
24 _tprintf(_T("service to start - %s\n\n"), ServiceName
);
25 _tprintf(_T("Arguments :\n"));
28 printf("%s\n", *ServiceArgs
);
34 /* get a handle to the service requested for starting */
35 hSc
= OpenService(hSCManager
, ServiceName
, SERVICE_ALL_ACCESS
);
39 _tprintf(_T("openService failed\n"));
44 /* start the service opened */
45 if (! StartService(hSc
, ArgCount
, ServiceArgs
))
47 _tprintf(_T("StartService failed\n"));
52 if (! QueryServiceStatusEx(
54 SC_STATUS_PROCESS_INFO
,
55 (LPBYTE
)&ServiceStatus
,
56 sizeof(SERVICE_STATUS_PROCESS
),
59 _tprintf(_T("QueryServiceStatusEx 1 failed\n"));
65 while (ServiceStatus
.dwCurrentState
== SERVICE_START_PENDING
)
67 /* wait before checking status */
68 Sleep(ServiceStatus
.dwWaitHint
);
70 /* check status again */
71 if (! QueryServiceStatusEx(
73 SC_STATUS_PROCESS_INFO
,
74 (LPBYTE
)&ServiceStatus
,
75 sizeof(SERVICE_STATUS_PROCESS
),
78 _tprintf(_T("QueryServiceStatusEx 2 failed\n"));
84 CloseServiceHandle(hSc
);
86 if (ServiceStatus
.dwCurrentState
== SERVICE_RUNNING
)
88 _tprintf(_T("%s is running\n"), ServiceName
);
93 _tprintf(_T("Failed to start %s\n"), ServiceName
);
94 _tprintf(_T("Curent state: %lu\n"), ServiceStatus
.dwCurrentState
);
95 _tprintf(_T("Exit code: %lu\n"), ServiceStatus
.dwWin32ExitCode
);
96 _tprintf(_T("Service Specific exit code: %lu\n"),
97 ServiceStatus
.dwServiceSpecificExitCode
);
98 _tprintf(_T("Check point: %lu\n"), ServiceStatus
.dwCheckPoint
);
99 _tprintf(_T("Wait hint: %lu\n"), ServiceStatus
.dwWaitHint
);