SC Create command syntax

This topic describes the various options of the SC command with the Create command option.

The SC command communicates with the Windows Service Controller and installed services. When used with its create command option, you can use it to create a Windows service under which the MDEX Engine will run.

The SC Create command uses the following format:
sc [remoteServername] create Servicename 
   binpath= "path\to\dgraph.exe dgraphFlags path\to\mdex_db" 
   [Optionname= Optionvalue...]
where:
  • remoteServername is an optional parameter that specifies the name of the server if you want to run the command on a remote computer. The name must start with two backslash (\) characters. Do not use this parameter if you are running SC on the local computer.
  • create is the command to be run by SC (this command name is mandatory to create a service).
  • Servicename is the name of the Windows service to be created. This is the name given to the service key in the registry. Note that this name is different from the display name.
  • binpath is a mandatory parameter that specifies information for the dgraph.exe command.
  • Optionname specifies optional parameters, which are described in the table below.
The binpath parameter specifies this information for the dgraph.exe command:
  • The absolute path to the dgraph.exe command.
  • The Dgraph flags used when the MDEX Engine is started. Note that you must use the Dgraph --out flag when the MDEX Engine is run in service mode.
  • The absolute path to the Dgraph database (that is, the database created by the mkmdex utility). Be sure to use the same database name that was supplied to mkmdex (that is, do not use the "_indexes" suffix that was added by mkmdex).

A space must be used between the binpath parameter and its argument. You should also use double quotes around the argument.

SC Create options

You can use these SC Create options to further customize the Windows service. Note that the option name includes the equal sign, and a space is required between the equal sign and the option value.
Option Name/Values Meaning
type= <serviceType> The type of service to be created. Use the own parameter value, which means the service runs in its own process. It does not share an executable file with other services. This is the default for the sc create command. Note that other service types are available, but you should use the own value.
start= <startType> The start type for the service:
  • auto – A service that automatically starts each time the computer is restarted.
  • demand – A service that must be manually started. This is the default value if start= is not specified. demand maps to Manual in the Services Control Manager.
  • delayed-auto – The SCM supports delayed auto-start services to improve system performance at boot time without affecting the user experience. The SCM makes a list of delayed auto-start services during boot and starts them one at a time after the delay has passed, honoring dependencies. There is no specific time guarantee as to when the service will be started.
  • disabled – A service that cannot be started. To start a disabled service, change the start type to another start value.
error= <errorSeverity> The severity of error if the service does not start during boot:
  • normal – The error is logged and a message box is displayed informing the user that a service has failed to start. System startup will continue. This is the default setting.
  • severe – The error is logged (if possible). The computer attempts to restart with the last-known-good configuration. This could result in the computer being able to restart, but the service may still be unable to run.
  • critical – The error is logged (if possible). The computer attempts to restart with the last-known-good configuration. If the last-known-good configuration fails, system startup also fails, and the boot process halts with a Stop error.
  • ignore – The error is logged and startup continues. No notification is given to the user beyond recording the error in the Event Log.
group= <loadOrderGroup> Name of group of which this service is a member. The list of groups are stored in the registry under the ServiceGroupOrder key. Default is null.
tag= yes|no Do not use this parameter as tags are used only for device driver service types.
depend= <dependencies> Names of services or groups that must start before this service. Each name is separated by / (forward slash).
obj= <accountName> Name of the account under in the service will run. The specified account must exist and must be a valid account. Default is LocalSystem.
password= <password> Password of the obj account. A password is required if an account other than the LocalSystem account is used.
displayname= <displayName> A friendly, meaningful name that can be used in user-interface programs to identify the service to users. For example, if the service name is MService, you can specify Endeca MDEX Engine as the display name so that will be more meaningful when shown in the Windows Services Control Manager.

SC Create example

The following SC Create example creates a Windows service for the MDEX Engine (note that the command is on one line, but is indented here for ease of reading):
sc create MDEXService displayname= "Endeca MDEX Engine" 
   type= own error= severe obj= "CORPDEV\EndecaUser" password= banx912
   binpath= "c:\endeca\latitude\2.1.0\mdex\bin\dgraph.exe --port 5555
     --threads 4 
     --pidfile c:\mdex_db\dgraph.pid
     --log c:\mdex_db\dgraph.log 
     --out c:\mdex_db\dgraph.out c:\mdex_db\mdexdb"
The sample command does the following:
  • Creates a Windows service named MDEXService.
  • Uses Endeca MDEX Engine as the display name for the service.
  • Sets the service type as own (which means the service runs in its own process).
  • Sets severe as the severity of error if the service does not start during the boot process.
  • Specifies that the service run under the CORPDEV\EndecaUser user account, which has banx912 as its password.
  • Sets the binary path of the dgraph.exe executable and specifies c:\mdex_db\mdexdb as the MDEX Engine database prefix. Also specifies the locations of the dgraph and error logs and the Dgraph PID file.

For ease of use, you can place the command in a batch script.