[SC] Support the paramchange and netbind* control codes in the control command

This commit is contained in:
Eric Kohl 2018-02-25 14:08:16 +01:00
parent 9f0c54fcd3
commit a0d412b77a
2 changed files with 26 additions and 6 deletions

View file

@ -157,19 +157,35 @@ ScControl(LPCTSTR Server, // remote machine name
}
else if (!lstrcmpi(Command, _T("control")))
{
INT CtlValue;
INT ControlCode = 0;
if (ArgCount > 1)
{
ServiceName = *ServiceArgs++;
ArgCount--;
CtlValue = _ttoi(ServiceArgs[0]);
if (!lstrcmpi(ServiceArgs[0], _T("paramchange")))
ControlCode = SERVICE_CONTROL_PARAMCHANGE;
else if (!lstrcmpi(ServiceArgs[0], _T("netbindadd")))
ControlCode = SERVICE_CONTROL_NETBINDADD;
else if (!lstrcmpi(ServiceArgs[0], _T("netbindremove")))
ControlCode = SERVICE_CONTROL_NETBINDREMOVE;
else if (!lstrcmpi(ServiceArgs[0], _T("netbindenable")))
ControlCode = SERVICE_CONTROL_NETBINDENABLE;
else if (!lstrcmpi(ServiceArgs[0], _T("netbinddisable")))
ControlCode = SERVICE_CONTROL_NETBINDDISABLE;
else
{
ControlCode = _ttoi(ServiceArgs[0]);
if ((ControlCode < 128) && (ControlCode > 255))
ControlCode = 0;
}
ServiceArgs++;
ArgCount--;
if ((CtlValue >= 128) && (CtlValue <= 255))
Control(CtlValue,
if (ControlCode != 0)
Control(ControlCode,
ServiceName,
ServiceArgs,
ArgCount);

View file

@ -169,9 +169,13 @@ VOID CreateUsage(VOID)
VOID ControlUsage(VOID)
{
_tprintf(_T("DESCRIPTION:\n")
_T(" Sends a CONTROL control request to a service.\n")
_T(" Sends a CONTROL code to a service.\n")
_T("USAGE:\n")
_T(" sc <server> control [service name] <value>\n"));
_T(" sc <server> control [service name] <value>\n")
_T(" <value> = user-defined control code\n")
_T(" <value> = <paramchange|\n")
_T(" netbindadd|netbindremove|\n")
_T(" netbindenable|netbinddisable>\n"));
}
VOID SdShowUsage(VOID)