2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
7 * PROGRAMMERS: Magnus Olsen (greatlord@reactos.org)
12 INT
cmdStop(INT argc
, WCHAR
**argv
)
14 SC_HANDLE hManager
= NULL
;
15 SC_HANDLE hService
= NULL
;
16 SERVICE_STATUS ServiceStatus
;
17 DWORD dwError
= ERROR_SUCCESS
;
23 PrintResourceString(IDS_STOP_SYNTAX
);
27 for (i
= 2; i
< argc
; i
++)
29 if (_wcsicmp(argv
[i
], L
"/help") == 0)
31 PrintResourceString(IDS_STOP_HELP
);
36 hManager
= OpenSCManagerW(NULL
,
37 SERVICES_ACTIVE_DATABASE
,
38 SC_MANAGER_ENUMERATE_SERVICE
);
41 dwError
= GetLastError();
46 hService
= OpenServiceW(hManager
,
51 dwError
= GetLastError();
56 if (!ControlService(hService
, SERVICE_CONTROL_STOP
, &ServiceStatus
))
58 dwError
= GetLastError();
65 CloseServiceHandle(hService
);
68 CloseServiceHandle(hManager
);
70 if (dwError
!= ERROR_SUCCESS
)
72 /* FIXME: Print proper error message */
73 printf("Error: %lu\n", dwError
);