sc.exe now supports basic starting, stopping, creation and deletion of services. 
Still early days and very bare bones, so not including into build yet
Modified: trunk/reactos/subsys/system/sc/control.c
Modified: trunk/reactos/subsys/system/sc/create.c
Modified: trunk/reactos/subsys/system/sc/delete.c
Modified: trunk/reactos/subsys/system/sc/query.c
Modified: trunk/reactos/subsys/system/sc/sc.c
Modified: trunk/reactos/subsys/system/sc/sc.h
Modified: trunk/reactos/subsys/system/sc/start.c
Modified: trunk/reactos/subsys/system/sc/usage.c

Modified: trunk/reactos/subsys/system/sc/control.c
--- trunk/reactos/subsys/system/sc/control.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/control.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -16,14 +16,26 @@
  * control, continue, interrogate, pause, stop
  */
 
-BOOL Control(DWORD Control, TCHAR **Args)
+BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
 {
     SC_HANDLE hSc;
     SERVICE_STATUS Status;
-    LPCTSTR ServiceName = *Args;
+    
+    /* testing */
+    _tprintf(_T("service to control - %s\n\n"), ServiceName);
+    _tprintf(_T("command - %lu\n\n"), Control);
+    _tprintf(_T("Arguments :\n"));
+    while (*Args)
+    {
+        printf("%s\n", *Args);
+        Args++;
+    }
 
 
-    hSc = OpenService(hSCManager, ServiceName, DELETE);
+    hSc = OpenService(hSCManager, ServiceName,
+                      SERVICE_INTERROGATE | SERVICE_PAUSE_CONTINUE |
+                      SERVICE_STOP | SERVICE_USER_DEFINED_CONTROL |
+                      SERVICE_QUERY_STATUS);
 
     if (hSc == NULL)
     {
@@ -40,6 +52,9 @@
     }
 
     CloseServiceHandle(hSc);
+    
+    /* print the status information */
+    
     return TRUE;
 
 }

Modified: trunk/reactos/subsys/system/sc/create.c
--- trunk/reactos/subsys/system/sc/create.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/create.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -11,13 +11,15 @@
 
 #include "sc.h"
 
-BOOL Create(TCHAR **Args)
+BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
 {
     SC_HANDLE hSc;
-    LPCTSTR ServiceName = *Args;
-    LPCTSTR BinaryPathName = *++Args;
-    LPCTSTR *Options = (LPCTSTR *)++Args;
+    LPCTSTR BinaryPathName = *++ServiceArgs;
+    LPCTSTR *Options = ++ServiceArgs;
     
+    if ((! ServiceName) || (! BinaryPathName))
+        return CreateUsage();
+    
     /* testing */
     printf("service to create - %s\n", ServiceName);
     printf("Binary path - %s\n", BinaryPathName);
@@ -28,7 +30,6 @@
         Options++;
     }
 
-
     hSc = CreateService(hSCManager,
                         ServiceName,
                         ServiceName,

Modified: trunk/reactos/subsys/system/sc/delete.c
--- trunk/reactos/subsys/system/sc/delete.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/delete.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -11,10 +11,9 @@
 
 #include "sc.h"
 
-BOOL Delete(TCHAR **Args)
+BOOL Delete(LPCTSTR ServiceName)
 {
     SC_HANDLE hSc;
-    LPCTSTR ServiceName = *Args;
 
     /* testing */
     printf("service to delete - %s\n\n", ServiceName);

Modified: trunk/reactos/subsys/system/sc/query.c
--- trunk/reactos/subsys/system/sc/query.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/query.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -12,32 +12,31 @@
 #include "sc.h"
 
 /* local function decs */
-VOID PrintService(ENUM_SERVICE_STATUS_PROCESS *pSStatus, BOOL bExtended);
+VOID PrintService(BOOL bExtended);
 INT EnumServices(DWORD ServiceType, DWORD ServiceState);
 
 /* global variables */
 static ENUM_SERVICE_STATUS_PROCESS *pServiceStatus = NULL;
 
-BOOL
-Query(TCHAR **Args, BOOL bExtended)
+
+BOOL Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended)
 {
             
-    LPCTSTR ServiceName = *Args;
-
-    if (! *Args)
+    if (! ServiceName)
     {
-        printf("Service name %s\n", ServiceName); // test
+        /* display all running services and drivers */
+        _tprintf(_T("No service name, displaying all services\n")); // test
 
         /* get default values */
         EnumServices(SERVICE_WIN32, SERVICE_ACTIVE);
         
         /* print default values */
-        PrintService(pServiceStatus, bExtended);
+        PrintService(bExtended);
     }
-    
-    if (_tcsicmp(Args[0], _T("type=")) == 0)
+    else if (_tcsicmp(ServiceName, _T("type=")) == 0)
     {
-        TCHAR *Type = *++Args;
+        LPCTSTR Type = *ServiceArgs;
+        
         _tprintf(_T("got type\narg = %s\n"), Type); // test
         if (_tcsicmp(Type, _T("driver")) == 0)
             EnumServices(SERVICE_DRIVER, SERVICE_STATE_ALL);
@@ -51,11 +50,11 @@
             _tprintf(_T("Must be \"driver\" or \"service\" or \"all\"\n"));
         }
         
-        PrintService(pServiceStatus, bExtended);
+        PrintService(bExtended);
     }
-    else if(_tcsicmp(Args[0], _T("state=")) == 0)
+    else if(_tcsicmp(ServiceName, _T("state=")) == 0)
     {
-        TCHAR *State = *++Args;
+        LPCTSTR State = *ServiceArgs;
 
         if (_tcsicmp(State, _T("active")) == 0)
             EnumServices(SERVICE_DRIVER|SERVICE_WIN32, SERVICE_ACTIVE);
@@ -69,27 +68,27 @@
             _tprintf(_T("Must be \"active\" or \"inactive\" or \"all\"\n"));
         }
             
-        PrintService(pServiceStatus, bExtended);
+        PrintService(bExtended);
     }
+/*
+    else if(_tcsicmp(ServiceName, _T("bufsize=")))
+
+    else if(_tcsicmp(ServiceName, _T("ri=")))
+
+    else if(_tcsicmp(ServiceName, _T("group=")))
+*/
     else
     {
-        printf("no args\n"); // test
+        /* print only the service requested */
+        printf("Service name %s\n", ServiceName); // test
+
         /* get default values */
         EnumServices(SERVICE_WIN32, SERVICE_ACTIVE);
 
         /* print default values */
-        PrintService(pServiceStatus, bExtended);
+        PrintService(bExtended);
     }
 
-/*
-    else if(_tcsicmp(Args[0], _T("bufsize=")))
-
-    else if(_tcsicmp(Args[0], _T("ri=")))
-
-    else if(_tcsicmp(Args[0], _T("group=")))
-*/
-
-
 }
 
 
@@ -100,6 +99,8 @@
     DWORD BytesNeeded = 0;
     DWORD NumServices = 0;
     DWORD ResumeHandle = 0;
+    
+//    hSc = OpenService(hSCManager, ServiceName, SERVICE_QUERY_STATUS);
 
     /* determine required buffer size */
     if (! EnumServicesStatusEx(hSCManager,
@@ -147,8 +148,7 @@
 
 
 VOID
-PrintService(ENUM_SERVICE_STATUS_PROCESS *pServiceStatus,
-                    BOOL bExtended)
+PrintService(BOOL bExtended)
 {
     _tprintf(_T("SERVICE_NAME: %s\n"), pServiceStatus->lpServiceName);
     _tprintf(_T("DISPLAY_NAME: %s\n"), pServiceStatus->lpDisplayName);

Modified: trunk/reactos/subsys/system/sc/sc.c
--- trunk/reactos/subsys/system/sc/sc.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/sc.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -44,8 +44,14 @@
 }
 
 
-INT ScControl(LPTSTR MachineName, LPCTSTR Command, TCHAR **Args)
+INT ScControl(LPTSTR MachineName,   // remote machine name
+              LPCTSTR Command,      // sc command
+              LPCTSTR ServiceName,  // name of service
+              LPCTSTR *ServiceArgs, // any options
+              DWORD ArgCount)       // argument counter
 {
+    /* count trailing arguments */
+    ArgCount -= 3;
 
     if (MachineName)
     {
@@ -61,66 +67,66 @@
         return -1;
     }
 
-
+    /* emurate command */
     if (_tcsicmp(Command, _T("query")) == 0)
-        Query(Args, FALSE);
+        Query(ServiceName, ServiceArgs, FALSE);
         
     else if (_tcsicmp(Command, _T("queryex")) == 0)
-        Query(Args, TRUE);
+        Query(ServiceName, ServiceArgs, TRUE);
         
     else if (_tcsicmp(Command, _T("start")) == 0)
     {
-        if (*Args)
-            Start(0, Args);
+        if (ServiceName)
+            Start(ServiceName, ServiceArgs, ArgCount);
         else
             StartUsage();
     }
     else if (_tcsicmp(Command, _T("pause")) == 0)
     {
-        if (*Args)
-            Control(SERVICE_CONTROL_PAUSE, Args);
+        if (ServiceName)
+            Control(SERVICE_CONTROL_PAUSE, ServiceName, ServiceArgs);
         else
             PauseUsage();
     }
     else if (_tcsicmp(Command, _T("interrogate")) == 0)
     {
-        if (*Args)
-            Control(SERVICE_CONTROL_INTERROGATE, Args);
+        if (ServiceName)
+            Control(SERVICE_CONTROL_INTERROGATE, ServiceName, ServiceArgs);
         else
             InterrogateUsage();
     }
     else if (_tcsicmp(Command, _T("stop")) == 0)
     {
-        if (*Args)
-            Control(SERVICE_CONTROL_STOP, Args);
+        if (ServiceName)
+            Control(SERVICE_CONTROL_STOP, ServiceName, ServiceArgs);
         else
             StopUsage();
     }
     else if (_tcsicmp(Command, _T("continue")) == 0)
     {
-        if (*Args)
-            Control(SERVICE_CONTROL_CONTINUE, Args);
+        if (ServiceName)
+            Control(SERVICE_CONTROL_CONTINUE, ServiceName, ServiceArgs);
         else
             ContinueUsage();
     }
     else if (_tcsicmp(Command, _T("delete")) == 0)
     {
-        if (*Args)
-            Delete(Args);
+        if (ServiceName)
+            Delete(ServiceName);
         else
             DeleteUsage();
     }
     else if (_tcsicmp(Command, _T("create")) == 0)
     {
-        if (*Args)
-            Create(Args);
+        if (*ServiceArgs)
+            Create(ServiceName, ServiceArgs);
         else
             CreateUsage();
     }
     else if (_tcsicmp(Command, _T("control")) == 0)
     {
-        if (*Args)
-            Control((DWORD)NULL, ++Args);
+        if (ServiceName)
+            Control((DWORD)NULL, ServiceName, ServiceArgs);
         else
             ContinueUsage();
     }
@@ -130,10 +136,9 @@
 
 int _tmain(DWORD argc, LPCTSTR argv[])
 {
-    LPTSTR MachineName = NULL;  // remote machine
-    LPCTSTR Command = argv[1];  // sc command
-    TCHAR **Args = NULL;        // rest of args
-    
+    LPTSTR MachineName = NULL;   // remote machine
+    LPCTSTR Command = NULL;      // sc command
+    LPCTSTR ServiceName = NULL;  // Name of service
 
     if (argc < 2)
         return MainUsage();
@@ -146,13 +151,16 @@
 
         _tcscpy(MachineName, argv[1]);
         Command = argv[2];
-        Args = (TCHAR **)&argv[3];
-        return ScControl(MachineName, Command, Args);
+        if (argc > 3)
+            ServiceName = argv[3];
+        return ScControl(MachineName, Command, ServiceName,  &argv[4], argc);
     }
     else
     {
-        Args = (TCHAR **)&argv[2];
-        return ScControl(MachineName, Command, Args);
+        Command = argv[1];
+        if (argc > 2)
+            ServiceName = argv[2];
+        return ScControl(MachineName, Command, ServiceName, &argv[3], argc);
     }
 
     return MainUsage();

Modified: trunk/reactos/subsys/system/sc/sc.h
--- trunk/reactos/subsys/system/sc/sc.h	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/sc.h	2005-11-04 18:19:09 UTC (rev 19000)
@@ -7,11 +7,11 @@
 //#define DBG
 
 /* control functions */
-BOOL Query(TCHAR **Args, BOOL bExtended);
-BOOL Start(INT ArgCount, TCHAR **Args);
-BOOL Create(TCHAR **Args);
-BOOL Delete(TCHAR **Args);
-BOOL Control(DWORD Control, TCHAR **Args);
+BOOL Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended);
+BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount);
+BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs);
+BOOL Delete(LPCTSTR ServiceName);
+BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args);
 
 /* print and error functions */
 DWORD ReportLastError(VOID);
@@ -25,3 +25,5 @@
 INT StopUsage(VOID);
 INT ConfigUsage(VOID);
 INT DescriptionUsage(VOID);
+INT DeleteUsage(VOID);
+INT CreateUsage(VOID);

Modified: trunk/reactos/subsys/system/sc/start.c
--- trunk/reactos/subsys/system/sc/start.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/start.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -11,14 +11,11 @@
 
 #include "sc.h"
 
-BOOL Start(INT ArgCount, TCHAR **Args)
+BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount)
 {
     SC_HANDLE hSc;
     SERVICE_STATUS_PROCESS ServiceStatus;
-    LPCTSTR ServiceName = *Args++;
-    LPCTSTR *ServiceArgs = (LPCTSTR *)Args;
     DWORD BytesNeeded;
-    
 
     /* testing */
     _tprintf(_T("service to start - %s\n\n"), ServiceName);
@@ -28,8 +25,7 @@
         printf("%s\n", *ServiceArgs);
         ServiceArgs++;
     }
-	if (! *ServiceArgs)
-		ServiceArgs = NULL;
+    
 
     /* get a handle to the service requested for starting */
     hSc = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS);

Modified: trunk/reactos/subsys/system/sc/usage.c
--- trunk/reactos/subsys/system/sc/usage.c	2005-11-04 16:49:37 UTC (rev 18999)
+++ trunk/reactos/subsys/system/sc/usage.c	2005-11-04 18:19:09 UTC (rev 19000)
@@ -142,13 +142,25 @@
 
 INT CreateUsage(VOID)
 {
-    _tprintf(_T("DESCRIPTION:\n")
-                _T("Creates a service entry in the registry and Service Database.\n")
-                _T("        If the service is running, or another process has an\n")
-                _T("        open handle to the service, the service is simply marked\n")
-                _T("        for deletion.\n")
-                _T("USAGE:\n")
-                _T("        sc <server> delete [service name]\n"));
+    _tprintf(_T("Creates a service entry in the registry and Service Database.\n")
+                _T("SYNTAX:\n")
+                _T("sc create [service name] [binPath= ] <option1> <option2>...\n")
+                _T("CREATE OPTIONS:\n")
+                _T("NOTE: The option name includes the equal sign.\n")
+                _T(" type= <own|share|interact|kernel|filesys|rec>\n")
+                _T("       (default = own)\n")
+                _T(" start= <boot|system|auto|demand|disabled>\n")
+                _T("       (default = demand)\n")
+                _T(" error= <normal|severe|critical|ignore>\n")
+                _T("       (default = normal)\n")
+                _T(" binPath= <BinaryPathName>\n")
+                _T(" group= <LoadOrderGroup>\n")
+                _T(" tag= <yes|no>\n")
+                _T(" depend= <Dependencies(separated by / (forward slash))>\n")
+                _T(" obj= <AccountName|ObjectName>\n")
+                _T("       (default = LocalSystem)\n")
+                _T(" DisplayName= <display name>\n")
+                _T(" password= <password>\n"));
 
     return 0;
 }