Author: ekohl
Date: Sun Jun 12 19:18:15 2016
New Revision: 71627
URL:
http://svn.reactos.org/svn/reactos?rev=71627&view=rev
Log:
[SC]
- Add the 'description' command.
- Fix a little display bug in the 'qdescription' command: Do not print
'(null)' if the service does not have a description.
Added:
trunk/reactos/base/applications/sc/description.c (with props)
Modified:
trunk/reactos/base/applications/sc/CMakeLists.txt
trunk/reactos/base/applications/sc/qdescription.c
trunk/reactos/base/applications/sc/sc.c
trunk/reactos/base/applications/sc/sc.h
trunk/reactos/base/applications/sc/usage.c
Modified: trunk/reactos/base/applications/sc/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/CMake…
==============================================================================
--- trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] Sun Jun 12 19:18:15
2016
@@ -5,6 +5,7 @@
control.c
create.c
delete.c
+ description.c
print.c
qc.c
qdescription.c
Added: trunk/reactos/base/applications/sc/description.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/descr…
==============================================================================
--- trunk/reactos/base/applications/sc/description.c (added)
+++ trunk/reactos/base/applications/sc/description.c [iso-8859-1] Sun Jun 12 19:18:15
2016
@@ -0,0 +1,60 @@
+/*
+ * PROJECT: ReactOS Services
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: base/applications/sc/description.c
+ * PURPOSE: Change the service description
+ * COPYRIGHT: Copyright 2016 Eric Kohl
+ *
+ */
+
+#include "sc.h"
+
+BOOL SetDescription(LPCTSTR ServiceName, LPCTSTR Description)
+{
+ SC_HANDLE hManager = NULL;
+ SC_HANDLE hService = NULL;
+ BOOL bResult = TRUE;
+ SERVICE_DESCRIPTION ServiceDescription;
+
+#ifdef SCDBG
+ _tprintf(_T("service to set description - %s\n\n"), ServiceName);
+#endif
+
+ hManager = OpenSCManager(NULL,
+ NULL,
+ SC_MANAGER_CONNECT);
+ if (hManager == NULL)
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+ hService = OpenService(hManager, ServiceName, SERVICE_CHANGE_CONFIG);
+ if (hService == NULL)
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+ ServiceDescription.lpDescription = (LPTSTR)Description;
+
+ if (!ChangeServiceConfig2(hService,
+ SERVICE_CONFIG_DESCRIPTION,
+ (LPBYTE)&ServiceDescription))
+ {
+ bResult = FALSE;
+ goto done;
+ }
+
+done:
+ if (bResult == FALSE)
+ ReportLastError();
+
+ if (hService)
+ CloseServiceHandle(hService);
+
+ if (hManager)
+ CloseServiceHandle(hManager);
+
+ return bResult;
+}
Propchange: trunk/reactos/base/applications/sc/description.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/sc/qdescription.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/qdesc…
==============================================================================
--- trunk/reactos/base/applications/sc/qdescription.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/qdescription.c [iso-8859-1] Sun Jun 12 19:18:15
2016
@@ -69,7 +69,8 @@
}
_tprintf(_T("SERVICE_NAME: %s\n"), ServiceName);
- _tprintf(_T(" DESCRIPTION : %s\n"),
pServiceDescription->lpDescription);
+ _tprintf(_T(" DESCRIPTION : %s\n"),
+ (pServiceDescription->lpDescription) ?
pServiceDescription->lpDescription : _T(""));
done:
if (bResult == FALSE)
Modified: trunk/reactos/base/applications/sc/sc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.c?…
==============================================================================
--- trunk/reactos/base/applications/sc/sc.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/sc.c [iso-8859-1] Sun Jun 12 19:18:15 2016
@@ -244,6 +244,26 @@
else
QueryFailureUsage();
}
+ else if (!lstrcmpi(Command, _T("description")))
+ {
+ LPCTSTR Description = NULL;
+
+ if (ArgCount > 0)
+ {
+ ServiceName = *ServiceArgs++;
+ ArgCount--;
+
+ if (ArgCount > 0)
+ {
+ Description = *ServiceArgs++;
+ ArgCount--;
+ }
+
+ SetDescription(ServiceName, Description);
+ }
+ else
+ SetDescriptionUsage();
+ }
else
{
MainUsage();
Modified: trunk/reactos/base/applications/sc/sc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.h?…
==============================================================================
--- trunk/reactos/base/applications/sc/sc.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/sc.h [iso-8859-1] Sun Jun 12 19:18:15 2016
@@ -23,6 +23,7 @@
BOOL SdSet(LPCTSTR ServiceName, LPCTSTR SecurityDescriptor);
BOOL QueryConfig(LPCTSTR ServiceName);
BOOL QueryDescription(LPCTSTR ServiceName);
+BOOL SetDescription(LPCTSTR ServiceName, LPCTSTR Description);
BOOL QueryFailure(LPCTSTR ServiceName);
/* print and error functions */
@@ -46,5 +47,6 @@
VOID QueryConfigUsage(VOID);
VOID QueryDescriptionUsage(VOID);
VOID QueryFailureUsage(VOID);
+VOID SetDescriptionUsage(VOID);
#endif /* _SC_PCH_ */
Modified: trunk/reactos/base/applications/sc/usage.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/usage…
==============================================================================
--- trunk/reactos/base/applications/sc/usage.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/sc/usage.c [iso-8859-1] Sun Jun 12 19:18:15 2016
@@ -34,7 +34,7 @@
_T("\t continue : Sends a CONTINUE control request to a
service.\n")
_T("\t stop : Sends a STOP request to a service.\n")
// "\t config : Changes the configuration of a service
(persistant).\n"
-// "\t description : Changes the description of a service.\n"
+ _T("\t description : Changes the description of a service.\n")
// "\t failure : Changes the actions taken by a service upon
failure.\n"
_T("\t qc : Queries the configuration information for a
service.\n")
_T("\t qdescription : Queries the description for a service.\n")
@@ -230,3 +230,11 @@
_T("USAGE:\n")
_T(" sc <server> qfailure [service name]
<bufferSize>\n"));
}
+
+VOID SetDescriptionUsage(VOID)
+{
+ _tprintf(_T("DESCRIPTION:\n")
+ _T(" Sets the description string of a service.\n")
+ _T("USAGE:\n")
+ _T(" sc <server> description [service name]
[description]\n"));
+}