mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[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. svn path=/trunk/; revision=71627
This commit is contained in:
parent
b3bcb0725a
commit
3746117c61
6 changed files with 94 additions and 2 deletions
|
@ -5,6 +5,7 @@ list(APPEND SOURCE
|
|||
control.c
|
||||
create.c
|
||||
delete.c
|
||||
description.c
|
||||
print.c
|
||||
qc.c
|
||||
qdescription.c
|
||||
|
|
60
reactos/base/applications/sc/description.c
Normal file
60
reactos/base/applications/sc/description.c
Normal file
|
@ -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;
|
||||
}
|
|
@ -69,7 +69,8 @@ BOOL QueryDescription(LPCTSTR ServiceName)
|
|||
}
|
||||
|
||||
_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)
|
||||
|
|
|
@ -244,6 +244,26 @@ ScControl(LPCTSTR Server, // remote machine name
|
|||
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();
|
||||
|
|
|
@ -23,6 +23,7 @@ BOOL SdShow(LPCTSTR ServiceName);
|
|||
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 SdSetUsage(VOID);
|
|||
VOID QueryConfigUsage(VOID);
|
||||
VOID QueryDescriptionUsage(VOID);
|
||||
VOID QueryFailureUsage(VOID);
|
||||
VOID SetDescriptionUsage(VOID);
|
||||
|
||||
#endif /* _SC_PCH_ */
|
||||
|
|
|
@ -34,7 +34,7 @@ VOID MainUsage(VOID)
|
|||
_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 @@ VOID QueryFailureUsage(VOID)
|
|||
_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"));
|
||||
}
|
Loading…
Reference in a new issue