One of the advantages of Windows services is the fact that you can launch them automatically at a certain time of the day or on the specific date. This is particularly useful if you want to run CPU/RAM/HDD access consuming application (backup, for instance) at the time when it will not affect other users.
You can start the service at a certain time using the graphical user interface
or command line options.
Whichever method you choose you can run it without any problems, however we recommend using the GUI until you get more experience.
1. Start the service graphical user interface
- If the service you want to run doesn’t exist, please, create it (you can refer to How to create system service section). Alternatively, select it from Services list and click "Edit" button on Toolbar, or right-click it and select "Edit" option from the context menu. As the result, "Create service" or "Edit service" dialog will appear.
- Please, select "Schedule" tab and specify the start time, stop time, day of the week or month, in other words, a certain time when you want your service to be started.
- Finally, click "Add" button.
- Note, that you can add several schedule tasks which will cooperate with each other. Use "Delete" to delete or "Up"/"Down" buttons to move the selected record to the top or to the bottom.
- Start the new service (or restart the existing one) by selecting it from Services list and pressing F5 functional key. This service will launch your application at the specified time. Please, note that your application will run in the background (will be visible in Service Control Manager only) unless you have enabled "Interaction with desktop" option.
2. Start the service at the specific time/on a certain date using command line
- Install the service by typing the full path to app2srv.exe file (by default it is "c:\Program Files\Eltima Software\Application as Service\", alternatively you can add this path to Path environment variable), INSTALL and providing all necessary command line options. For instance:
c:\Program Files\Eltima Software\Application as Service\app2srv.exe INSTALL /SN="Notepad" /PM="C:\WINDOWS\System32\notepad.exe" /SCD="13:00:00|||||D127" /SCD="||14:00:00|||D127"
- SN (Service Name) and PM (Executable file) parameters are mandatory. SCD (schedule) is the key, which actually defines the schedule date when your application will be launched or stopped. Its value is a string of parameters, one after another separated by vertical line.
Start time from
This is a 24-hour formatted time string that defines the start time of your application. For instance, 13:00:00 means that your application which is launched as service might be started at 1 PM local time.
command line example: /SCD="16:48:00|||||D127" means that application will be launched at 4:48 PM every day
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, your application might start till that time.
command line example: /SCD="16:48:00|17:00:00||||D127" means that application might be launched from 4:48 PM to 5 PM every day
Stop time
This is a 24-hour formatted time string that defines the stop time of your application which is launched as service. For instance, 14:00:00 means that the application should be stopped at 2 PM local time. Note, that you are not allowed to use "Stop time" option in the same SCD key if you used "Start time from … to …" parameters already. In other words, to use "Stop time" parameter create new SCD key.
For example, you want your application to be launched at 1 PM and stopped 2 PM every day. The schedule parameter should be the following: /SCD="13:00:00|||||D127" /SCD="||14:00:00|||D127", the wrong is: /SCD="13:00:00||14:00:00|||D127"
Start anytime
This option starts application any time according to the time condition.
Note, that "Start anytime" option should be used along with a certain date, week day or day of month.
Periodically
This option defines the time when your application, which is launched as service, might be started or stopped from one date to another.
command line example: /SCD="16:48:00|||28.02.2008|29.02.2008|D127" means that application might be launched at 4:48 PM everyday between February 28 and February 29
Daily
This option defines whether your application, which is launched as service, should start or stop on certain days of the week. By default, the application is allowed to run 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 Monday.
I.e. Monday equals 1, Tuesday equals 2, Wednesday equals 4, Thursday equals 8, Friday – 16, Saturday – 32 and Sunday – 64. For instance, if you want your service running on daily basis then the resulting string is D127.
command line example: /SCD="16:48:00|||||D3" means that application will be launched at 4:48 PM on Monday and Tuesday
Monthly
This option defines whether the 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 month or on monthly basis, 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 the 3rd day of each month, construct M3 string. M10-20 string means that your application should be launched or stopped between 10th and 20th days of the month.
command line example: /SCD="16:48:00|||||M10" means that application will be launched at 4:48 PM on 10 day of every month
Please, note that your application will run in the background unless you provide the /ID1 parameter ("Interaction with desktop" enabled) and set "Account" to "LocalSystem" (which is the default parameter and therefore can be omitted).
- Start the service by typing the full path to the app2srv.exe file, START and valid SN (Service Name) key. For instance:
c:\Program Files\Eltima Software\Application as Service\app2srv.exe START /SN=Notepad
Please note that if you have several items in your schedule (for example, start time at 17:00, stop time at 18:00, start time at 19:00 and stop time at 20:00) select "Restart the program after" option at Advanced tab if you want your schedule to be executed properly.