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] [/LG=string] [/ACT=user] [/PW=passw] [/IDx] [/SWx] [/STTx] [/SESID=1][/UPx] [/UT=sec] [/FPx] [/FR=number][/GSx] [/SDT=sec] [/IN=string] [/OUT=string][/OWR=1]( [/PRYx] [/CPUx] [/CF=number] [/RR=string] [/RM=string] [/ACN=\”x1|x2\”] [/DPS=service] [/ENV=string] [/PRE=string|string|string|sec] [/POST=string|string|string|sec]  [/SCD=time|time|date|date|rules] [/RUSR=user /RHOST=name/IP /RPWD=password]

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

OptionValueDescription
SNstringRequired parameter that is the valid name of the service you want to install. Note: whitespaces (such as spaces, tabs and punctuation) are not allowed.
PMstringRequired parameter that specifies the executable file which should be run as Windows service.
DISPstringOptional parameter which is shown in Windows Service Control Manager (SCM) in the “Name” column. Its value may contain whitespaces. If this value is not specified, SN is used instead.
DESstringOptional parameter that sets more descriptive information to the service and is displayed in SCM. Note: whitespaces (such as spaces, tabs and punctuation) are not allowed. If this value is not specified, DISP is used instead.
WDstringOptional parameter that defines the working directory of the service. If the folder is located on the remote host, specify the valid Universal/Uniform Naming Convention (UNC) path to the network drive (“//servername/full/path”).
PRMstringThis is an optional list of parameters that can be passed to executable at the start time. It may contain username, system or service specific environment variables (for instance, %MYVAR%), file name and so on.
CONbooleanOptional 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 the application is not console.
ACTstringOptional parameter that defines account name under which the service will run. As the result, the application you launch as service will have exactly the same execution rights, which is useful if you want to restrict or grant your application certain privileges. If the parameter is not specified, the service will run with rights under which Application as Service was launched.
PWstringOptional parameter that defines the password to the account specified by ACT parameter.
IDintegerOptional parameter that defines whether your application should be interactive (ID1), interactive and launched in Winlogon screen (ID2) or not interactive (ID0). By default the service is not interactive.
SESIDintegerOptional parameter that defines the session ID for the interactive service launch. If the required session is unavailable, the default one (zero) will be used.
SWcharOptional parameter that defines the display mode of the service and is applicable to the interactive services only. It may have one of the following values: SWN (Normal), SWH (Hidden – silently disables the Interact with Desktop field), SWI (Minimized) and SWX (Maximized).
LGstringOptional parameter that defines the name of the Load Order Group which the application you want to launch as service will belong to.
STTcharOptional parameter that defines the start-up type of the service. Its value can be: STTM (Manual), STTA (Automatic) or STTD (Disabled).
“Manual” type means that this service can be started at any time manually by the user, “Automatic” means that the service will be started automatically by Service Control Manager prior to login session and, finally, “Disabled” type means that the service will not 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”.
UPcharOptional parameter that defines the service behavior on termination of the application, which is run as service. It may have the following values: UPD (Disable), UPR (Restart the program after) and UPS (Shutdown the service).
UTintegerOptional parameter that defines the period of time (in seconds) between attempts to relaunch the application, and is applicable if you use it with UPR.
FPstringOptional parameter that defines how Service Control Manager should manage the service in case the application, which is run as service, terminates several times in succession. It may have the following values: FPD (Disable) and FPS (“Shutdown the service after” – will terminate the service by sending “Stop” command). This parameter is applicable if you specify UP equal to “Restart the program after” (UPR).
FRintegerOptional parameter that defines how many attempts to restart the application should be made before the Flap detection is enabled. This parameter is applicable if you use it with UPR.
GSstringOptional parameter that defines whether the graceful shutdown is enabled. GS1 means that graceful shutdown is enabled, and GS0 otherwise. Graceful shutdown ensures that the application, running as service, terminates correctly. Default value is GS1.
SDTintegerOptional parameter that defines the period of time (in seconds) before the application is forced to exit (in case it is not responding). This parameter is applicable if you specify GS1.
INstringOptional parameter that defines the name of the file from which STDIN (standard input) stream will be redirected.
OUTstringOptional parameter that defines the name of the file where STDOUT (standard output) and STDERROR (standard error) streams will be redirected to.
OWR stringOptional parameter that defines whether the output file should be overwritten at each service start.
By default this option is disabled. OWR=1 means that it is enabled.
PRYstringOptional parameter that defines the priority value of the process. It may have one of the following values:
PRYL (“Low” priority), PRYN (“Normal” priority used for the processes without special scheduling needs), PRYB (“Below Normal” priority used for the processes of 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 of 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).
CPUintegerOptional parameter that defines processor/processors that can be used by the service and is applicable to multi-processor systems only. The value is the sum of the processors where the first CPU is 1, the second is 2, the third is 4, the fourth – 8, the fifth – 16, the sixth – 32, the  seventh – 64, and the eighth – 128. Value 0 means that all processors are enabled.
ACN charOptional parameter that defines the action which should be taken if the application that runs as service is abruptly terminated. It consists of two parameters separated by a vertical line. The first one 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 is taken.
CF numberOptional parameter that defines the period of time (in hours) after which Application as Service should reset the failure count to zero if no failures occurred. Specify “-1” to indicate that this value should never be reset. CF parameter works if ACN is specified.
RRstringOptional parameter that defines the additional command-line executable that should be run on the application crash. This is applicable if ACN parameter is equal to “Run a program”.
RMstringOptional 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”.
DPSstringOptional parameter that defines group/groups which the service will depend upon. It MUST match the Service Name of the pre-existing service, otherwise the service will not start. If the certain group of services is not started you will be sent a warning message.
ENVstringOptional parameter that defines the list of environment variables that should be initialized on the service start and be accessible from within this service.
PREstringOptional 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 a vertical line. Those parameters are: Executable (the full path and name of the pre-service program), Working Directory (the full valid path to the working directory of the pre-service program), Parameters (the list of parameters that can be passed to the pre-service program), Execution Time (expected time to run the pre-service program). For instance: /PRE=”C:\notepad.exe|C:\||3000″
POSTstringOptional parameter that defines the additional application that should be launched once the service is stopped. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Executable (the full path and name of the post-service program), Working Directory (the full valid path to the working directory of the post-service program), Parameters (the list of parameters that can be passed to the post-service program) and Execution Time (expected time to run the post-service program). For instance: /POST=”C:\notepad.exe|C:\||3000″
RPRstringOptional parameter that defines the additional application that should be launched before the command to start the application, which is launched as service, is executed. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Executable (the full path and name of the pre-run program), Working Directory (the full valid path to the working directory of the pre-run program), Parameters (the list of parameters that can be passed to the pre-run program), Execution Time (expected time to run the pre-run program). For instance: /RPR=”C:\notepad.exe|C:\||3000″
RPOstringOptional parameter that defines the additional application that should be started immediately once the command to start the application, which is launched as service, is executed. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Executable (the full path and name of the post-run program), Working Directory (the full valid path to the working directory of the post-run program), Parameters (the list of parameters that can be passed to the post-run program), Execution Time (expected time to run the post-run program). For instance: /RPO=”C:\notepad.exe|C:\||3000″
EPRstringOptional parameter that defines the additional application that should be started every time before the command to stop the application, which is launched as service, is executed. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Executable (the full path and name of the pre-stop program), Working Directory (the full valid path to the working directory of the pre-stop program), Parameters (the list of parameters that can be passed to the pre-stop program), Execution Time (expected time to run the pre-stop program). For instance: /EPR=”C:\notepad.exe|C:\||3000″
EPOstringOptional parameter that defines the additional application that should be started immediately after the command to stop the application, which is launched as service, is executed. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Executable (the full path and name of the post-stop program), Working Directory (the full valid path to the working directory of the post-stop program), Parameters (the list of parameters that can be passed to the post-stop program), Execution Time (expected time to run the post-stop program). For instance: /EPO=”C:\notepad.exe|C:\||3000″
DBSstringOptional parameter that defines managing of various pop-up windows after your application is launched. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Caption text parent (caption text of the parent window, which will be searched for to execute certain commands), Class name parent (Windows system class name of the parent window), Caption text (caption text of the window, which will be searched for to execute certain commands), Class name (Windows system class name of the window), Wait time (time after which the command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be sent to a certain window). For instance: /DBS=”Notepad||&NO|Button|5000|1″
DPOstringOptional parameter that defines closure of various pop-up windows before your application is closed. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Caption text parent (caption text of the parent window, which will be searched for to execute certain commands), Class name parent (Windows system class name of the parent window), Caption text (caption text of the window, which will be searched for to execute certain commands), Class name (Windows system class name of the window), Wait time (time after which the command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be sent to a certain window). For instance: /DPO=”|||#32770|10000|0″
DEstringOptional parameter that defines closure of various pop-up windows after sending WM_CLOSE to your application. The value is the string of parameters separated from each other by a vertical line. Those parameters are: Caption text parent (caption text of the parent window, which will be searched for to execute certain commands), Class name parent (Windows system class name of the parent window), Caption text (caption text of the window, which will be searched for to execute certain commands), Class name (Windows system class name of the window), Wait time (time after which the command to close window or press button will be executed), Command to send: press button or close window (exact command, which will be sent to a certain window). For instance: /DE=”||&YES|Button|5000|1″
SCDstringOptional parameter that allows launching the service periodically at the specific time of the day, on the specific day of the week/month or on the specific date. Its value is a string of parameters separated by a 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 the service must 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, the service must 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:00 means that the service should be stopped at 12 AM local time.
  4. Start anytime
    This option starts application anytime according to the time condition.
  5. Periodically
    This option defines the time when your application, which is launched as service, must be started and stopped.
  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”. Weekdays’ values are raised to 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 run on a daily basis, the resulting string is D127.
  7. Monthly
    This is a string that defines whether the application, which is launched as service, should start or stop monthly between several days or on a certain day. In case you would like to run or stop it on the particular day of the month or monthly, specify the number of the day of the month (or the range of days), preceded by letter “M”. For example, if you want to run your application on the 3rd day of each month, construct M3 string. M10-20 string means that your application should be launched or stopped between the 10th and the 20th days of the month.

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

SACbooleanIf GS is enabled, you can use this parameter to stop console program.
SRVbooleanOptional parameter which value can be 0 – if you launch application as service, and 1 – if you create a new system service.
RHOSTstringOptional parameter that is the remote computer’s name or IP.
This parameter is applicable only together with RUSR and RPWD parameters. For OEM License owners only.
RUSRstringOptional parameter that is the administrator account name under which you want to login to the remote computer. This parameter is applicable only together with RHOST and RPWD parameters. For OEM License owners only.
RPWDstringOptional parameter that is the remote account password. This parameter is applicable only together with RHOST and RUSR parameters. For OEM License owners only.

Return value:
0 – if the command succeeds. Otherwise “-1” or the error code is returned.