Application as Service - INSTALL command

The INSTALL command installs the service with parameters you pass to it

Syntax:

			
  APP2SRV INSTALL 
      /SN=name /PM=name [/DISP=name] [/DES=string] [/WD=dir] [/PRM=string] [/CONx]
      [/ACT=user] [/PW=passw] [/IDx] [/SWx] [/LG=string]
      [/STTx] [/UPx] [/UT=msec]
      [/FPx] [/FR=msec][/GSx] [/SDT=msec] 
      [/IN=string] [/OUT=string]( [/PRYx] [/CPUx]
      [/CF=number] [/RR=string] [/RM=string] [/ACN="x1|x2"] 
      [/DPS=service] [/ENV=string] [/PRE=string|string|string|msec]
      [/POST=string|string|string|msec]  
      [/RPR=string|string|string|msec] [/RPO=string|string|string|msec]
      [/EPR=string|string|string|msec] [/EPO=string|string|string|msec]
      [/DBS=string|string|string|string|msec|comm] [/DPO=string|string|string|string|msec|comm]
      [/DE=string|string|string|string|msec|comm] [/SCD=time|time|date|date|rules] [/SACx] [/SRVx]!

Note: x is a character or the integer value. Parameters in square brackets are optional.

  Option Value Description
  SN string Required parameter that is a valid service name you want to install. Note: whitespaces (such as spaces, tabs and punctuation) are not allowed.
  PM string Required parameter that specifies the executable file which should be run as Windows service.
  DISP string Optional parameter which is shown in Windows Service Control Manager (SCM) at the "Name" column. Its value may contain whitespaces. If this value is not specified, the "SN" is used instead.
  DES string Optional parameter that sets more descriptive information for the service and is displayed in SCM. Note: whitespaces (such as spaces, tabs and punctuation) are not allowed. If this value is not specified, the "DISP" is used instead.
  WD string Optional parameter that defines the working directory of the service. If the folder located on remote host, please, specify the valid Universal/Uniform Naming Convention (UNC) path to a network drive ("//servername/full/path").
  PRM string This is an optional list of parameters that can be passed to the executable at the start time. It may contain username, system or service specific environment variables (for instance, %MYVAR%), file name and so on.
  CON boolean Optional parameter that defines whether the application you run as service is console one. Supply CON1 if this is console application and CON0 otherwise. If this parameter is not specified, it is assumed that application is not console.
  ACT string Optional parameter that defines account name under which the service will run. As the result, the application you launch as the service will has exactly the same execution rights, which is useful if you want to restrict or grant your application with the certain privileges. If the parameter is not specified, the service will run with rights under which it Application as Service was launched.
  PW string Optional parameter that defines the password for the account specified by ACT parameter.
  ID integer Optional parameter that defines whether your application should be interactive and launched in default way (ID1), interactive and launched in Winlogon screen (ID2) or not interactive (ID0). By default the service is not interactive.
  SW char Optional parameter that defines the service's display mode and is applicable for the interactive services only. It may have one of the following values: SWN (Normal), SWH (Hidden - silently causes the Interact with Desktop field to have no effect), SWI (Minimized) and SWX (Maximized).
  LG string Optional parameter that defines the name of the Load Order Group which the application you want to launch as service will belong to.
  STT char Optional parameter that defines the service start-up type of the service. Its value could be: STTM (Manual), STTA (Automatic) or STTD (Disabled). "Manual" type means that this service could be started at any time manually by user, "Automatic" means that service will be started automatically by Service Control Manager prior to login session and, finally, "Disabled" type means that service couldn't be started unless you change its status to something else. "Disabled" is useful if you want certain service be present but not running. The default value is "Manual".
  UP char Optional parameter that defines the service behavior on application termination. It may have the following values: UPD (Disable), UPR (Restart the program) and UPS (Shutdown the service).
  UT integer Optional parameter that defines the period of time (seconds) between attempts to re-launch the application and is applicable if you use it with UPR.
  FP string Optional parameter that defines how Service Control Manager should manage the service if was application termination several times in a row. It may have the following values: FPD (Disable) and FPS ("Shutdown the service" - will terminate the service by sending "Stop" command). This parameter is applicable if you specify UP equal to "Restart the program" (UPR).
  FR integer Optional parameter that defines how many attempts to restart the application were made before the Flap detection should be enabled. This parameter is applicable if you use it with UPR.
  GS string Optional parameter that defines whether the graceful shutdown is enabled. Set this parameter to GS1 is graceful shutdown is enable and GS0 otherwise. Graceful shutdown ensures that application, running as service terminated correctly. Default value is GS1.
  SDT integer Optional parameter that defines the period of time (in milliseconds) before the application will be forced to exit (in case it is not responding). This parameter is applicable if you specify GS1.
  IN string Optional parameter that defines the file name where STDIN (standard input) stream will be redirected from.
  OUT string Optional parameter that defines the file name where STDOUT (standard output) and STDERROR (standard error) stream will be redirected to.
  PRY string Optional parameter that defines the process's priority value. It may have one of the following values: PRYL ("Low" priority), PRYN ("Normal" priority used for the process with no special scheduling needs), PRYB ("Below Normal" priority used for the processes above Low priority but below Normal priority types. Not available for Windows 95/98/Me and NT), PRYA ("Above Normal" priority used for the processes above Normal priority but below High priority types. Not available for Windows 95/98/Me and NT), PRYH ("High" priority used for time-critical tasks that must be executed immediately) and PRYR (the highest possible priority).
  CPU integer Optional parameter that defines the processor/processors that could be used by the service and is applicable for multi-processor systems only. The value is a sum of the processors where the first CPU is 1, second is 2, third is 4, fourth = 8, fifth = 16, sixth = 32, seventh = 64 and eighth = 128. Value 0 means that all processors are enabled.
  ACN char Optional parameter that defines the action should be taken if the application that runs as service was abruptly terminated. It consists of two parameters separated by vertical line. The first on may have one of the following options: 0 - take no action, 1 - restart the service, 2 - restart computer, 3 - run a program. The second parameter sets the delay in minutes before the recovery action would be taken.
  CF number Optional parameter that defines the period of time (in hours) after which Application as Service should reset the failure count to zero if there are no failures occurred. Specify "-1" to indicate that this value should never be reset. CF parameter works if ACN is specified.
  RR string Optional parameter that defines additional command line executable and options that should be run on application crashes. This is applicable if ACN parameter is equal to "Run a program".
  RM string Optional parameter that defines the broadcast message which will be sent to all logged users on server reboot. This parameter is applicable if ACN is equal to "Reboot computer".
  DPS string Optional parameter that defines the group/groups which the service will depend upon. It MUST match the Service Name of
a pre-existing service or the service will not start. If the certain group of services is not started you will be sent a warning message.
  ENV string Optional parameter that defines the list of environment variables that be initialized on the service start and be accessible from within this service.
  PRE string Optional parameter that defines the additional application that should be launched prior to the service. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the pre-service program), Working Directory (a full valid path to the working directory of the pre-service application), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run pre-service application). For instance: /PRE="C:\notepad.exe|C:\||3000"
  POST string Optional parameter that defines the additional application that should be launched once to the service is stopped. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the post-service program), Working Directory (a full valid path to the working directory of the post-service application), Parameters (the list of parameters that can be passed to the post-service program) and Execution Time (expected time to run post-service application). For instance: /POST="C:\notepad.exe|C:\||3000"
  RPR string Optional parameter that defines the additional application that should be launched before command to start application, which is launched as service is executed. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the pre-service program), Working Directory (a full valid path to the working directory of the pre-service application), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run pre-service application). For instance: /RPR="C:\notepad.exe|C:\||3000"
  RPO string Optional parameter that defines the additional application that should be started immediately after command to start application, which is launched as service is executed. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the pre-service program), Working Directory (a full valid path to the working directory of the pre-service application), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run pre-service application). For instance: /RPO="C:\notepad.exe|C:\||3000"
  EPR string Optional parameter that defines the additional application that should be started every time before command to stop application, which is launched as service is executed. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the pre-service program), Working Directory (a full valid path to the working directory of the pre-service application), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run pre-service application). For instance: /EPR="C:\notepad.exe|C:\||3000"
  EPO string Optional parameter that defines the additional application that should be started immediately after command to stop application, which is launched as service is executed. The value is the string of parameters separated from each other by vertical line. Those parameters are: Executable (a full path and name of the pre-service program), Working Directory (a full valid path to the working directory of the pre-service application), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run pre-service application). For instance: /EPO="C:\notepad.exe|C:\||3000"
  DBS string Optional parameter that defines various popup windows managing after your application launch. The value is the string of parameters separated from each other by vertical line. Those parameters are: Caption text parent (caption text of parent window, which will be searched to execute certain commands), Class name parent (Windows system class name of parent window), Caption text (caption text of the window, which will be searched to execute certain commands), Class name (Windows system class name of the window), Wait time (time after which command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be send to certain window). For instance: /DBS="Notepad||&NO|Button|5000|1"
  DPO string Optional parameter that defines various popup windows closing before your application close. The value is the string of parameters separated from each other by vertical line. Those parameters are: Caption text parent (caption text of parent window, which will be searched to execute certain commands), Class name parent (Windows system class name of parent window), Caption text (caption text of the window, which will be searched to execute certain commands), Class name (Windows system class name of the window), Wait time ( time after which command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be send to certain window). For instance: /DPO="|||#32770|10000|0"
  DE string Optional parameter that defines various popup windows closing after sending WM_CLOSE to your application. The value is the string of parameters separated from each other by vertical line. Those parameters are: Caption text parent (caption text of parent window, which will be searched to execute certain commands), Class name parent (Windows system class name of parent window), Caption text (caption text of the window, which will be searched to execute certain commands), Class name (Windows system class name of the window), Wait time ( time after which command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be send to certain window). For instance: /DE="||&YES|Button|5000|1"
 

SCD

string

This is an optional parameter that allows launching the service periodically at the specific time of the day, day of the week/month or at the specified date. Its value is a string of parameters separated by vertical line:

 

  1. Start time from


    This is a 24-hour formatted time string that defines the start time of the service. For instance, 17:00 means that service might be launched at 5 PM local time.

  2. Start time to


    This is a 24-hour formatted time string that is active when "Start time from" parameter is used only and defines the end time, in other words, service might start till that time.

  3. Stop time

    This is a 24-hour formatted time string that defines the stop time of the service. For instance, 00:00means that service should be stopped at 12 AM local time.
     
  4. Start anytime
    This option starts application anytime according to time condition.
     
  5. Periodically
    This option defines time when your application which is launched as service might be started or stopped from one date to another.
     
  6. Daily
    This is a string that defines whether the service should run or stop on certain days of the week. By default, the application is allowed to run or stop on any day of the week. The resulting string should consist of the sum of the weekdays, preceded by letter "D". Weekday's values are the power of two starting from Sunday. I.e. Sunday equals 1, Monday equals 2, Tuesday equals 4, Wednesday equals 8, Thursday equals 16, Friday - 32 and Saturday - 64. For instance, if you want your service running on daily basis then the resulting string is D127.

     
  7. Monthly
    This is a string that defines whether application which is launched as service should start or stop monthly between several days or on certain day. In case you would like to run or stop it on particular day of the month or monthly basis then you should specify the number of month's day (or the range of the days) preceded by letter "M". For example, if you want to run your application on 3rd day of the each month then you should construct M3 string. M10-20 string means that your application should be launched or stopped between 10th and 20th days of the month.

For instance: /SCD="13:00:00|||||D127" /SCD="||14:00:00|||D127" strings mean that the service should be started at 1 AM and stopped at 2 AM every day.

  SAC boolean If GS is enabled, you can use this parameter to stop console program using the following values: "0" - CTRL_C_EVENT or "1" - CTRL_BREAK_EVENT.
  SRV boolean Optional parameter which value can be 0 - if you launch application as service and 1 - if you create new system service.