1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS net command
4  * FILE:            base/applications/network/net/cmdPause.c
5  * PURPOSE:
6  *
7  * PROGRAMMERS:     Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
8  */
9 
10 #include "net.h"
11 
12 INT cmdPause(INT argc, WCHAR **argv)
13 {
14     SC_HANDLE hManager = NULL;
15     SC_HANDLE hService = NULL;
16     SERVICE_STATUS status;
17     INT nError = 0;
18     INT i;
19 
20     if (argc != 3)
21     {
22         ConResPuts(StdOut, IDS_GENERIC_SYNTAX);
23         ConResPuts(StdOut, IDS_PAUSE_SYNTAX);
24         return 1;
25     }
26 
27     for (i = 2; i < argc; i++)
28     {
29         if (_wcsicmp(argv[i], L"/help") == 0)
30         {
31             ConResPuts(StdOut, IDS_GENERIC_SYNTAX);
32             ConResPuts(StdOut, IDS_PAUSE_SYNTAX);
33             ConResPuts(StdOut, IDS_PAUSE_HELP_1);
34             ConResPuts(StdOut, IDS_PAUSE_HELP_2);
35             return 1;
36         }
37     }
38 
39     hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
40     if (hManager == NULL)
41     {
42         ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
43         nError = 1;
44         goto done;
45     }
46 
47     hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
48     if (hService == NULL)
49     {
50         ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
51         nError = 1;
52         goto done;
53     }
54 
55     if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
56     {
57         ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
58     }
59 
60 done:
61     if (hService != NULL)
62         CloseServiceHandle(hService);
63 
64     if (hManager != NULL)
65         CloseServiceHandle(hManager);
66 
67     return nError;
68 }
69 
70 /* EOF */
71 
72