1. General information
- Scheduled tasks are programs that run in the background of the Windows operating system. Scheduled tasks are configured in the “Task Scheduler”.
- The purpose of scheduled tasks is to periodically run executable programs
- once a day, weekly or monthly at a given time (hour and minute) – for example at 04:00 in the morning,
- every day repeatedly from a given time (hour and minute) in a given interval (number of hours/minutes) and for a given time (number of hours) – for example from 06:00 in the morning in an interval of 30 minutes for 18 hours,
- or in any combination and using restrictions on specific days – for example
- every Monday, Wednesday and Friday at 22:00,
- on the first of January, March and June at 08:00 in the morning,
- etc.
1.1. Scripts on buttons (Button controls)
- NET Genium uses scheduled tasks to periodically run scripts, defined within buttons located on view pages.
- For simpler and more user-friendly scheduling of tasks, Setup.exe can be used, allowing task scheduling without directly modifying system settings.
- Run Setup.exe from the bin directory.
- Select the option to schedule a task for RunScript.exe, which appears among the last options in the interface.
- Enter the button ID of the script you want to schedule.
- Set the time and frequency for running the script and confirm by clicking “Setup”.
- The “RunScript.exe” program, located in the “bin” directory of each NET Genium, is used to run the script defined by the button.
- Use: “RunScript.exe <ID> [<UserID>]”
- The “ID” parameter means the ID of the button, and it can be found in the admin mode in the tooltip that appears after stopping the mouse pointer over the link “Edit Button ID ...” or over the link “Edit script”.
- The optional “UserID” parameter represents the ID of the user under whose login name the script will run. If the optional parameter is not specified, the script will run under an anonymous user, and print templates printed by the script are then generated regardless of access rights. With the parameter specified, the rights of the given user apply. Print templates are generated the same way in the scripts that the script starts with the “SCHEDULESCRIPT” server function.
- The whole script runs in one database transaction. However, an e-mail sent by the “Send email” step is sent immediately, so a later error of the script does not take it back. The “Config\Demo.txt” file prevents writes to the database as well as sending e-mails from the script.
- The program returns exit code 0 on successful completion and 1 on an error – also when the button script does not exist or is empty, or when a script run by the “SCHEDULESCRIPT” server function fails. The details of the error are in the “Errors” log.
- The “SCHEDULEPRINT” server function is not executed when the script is run by “RunScript.exe”.
- Using a scheduled task, it is not possible to directly run scripts defined within the buttons located in edit forms. However, this limitation can be easily solved by launching a button on the view page, which then launches a button located in the edit form using the server function “SCHEDULESCRIPT(int button, int id)”.
1.2. Service tools
- NET Genium also uses scheduled tasks to periodically run service tools:
- Backing up databases and files using “BackupServer.exe”
- Backing up databases using “SqlBackup.exe”
- Backing up file attachments with “FileBackup.exe”
- Automatically update NET Genium to the latest version using “Update.exe”
- Periodically sending failed emails from the “SMTP” directory using the “ResendEmlFiles.exe” program
2. Creating scheduled tasks with “Setup.exe” program
- “Setup.exe” is the recommended method for creating scheduled tasks associated with the execution of button scripts located on view pages. Scheduled tasks created by the “Setup.exe” program can also be manually configured directly in the “Task Scheduler”.
- All scheduled tasks are created in the “NET Genium” folder, which either already exists or is created by “Setup.exe”.
- Scheduled tasks are set to run in the context of the user account “SYSTEM” with the highest privileges.
- Run the “Setup.exe” program located in the “bin” directory of each NET Genium.

- Check the options you want to choose as described below:
- “Create scheduled task for BackupServer.exe (server backup)”
- Check this option if you want to automatically create a scheduled task for regular backups of the server – database and directory.
- “Create scheduled task for SqlBackup.exe (database backup)”
- Check this option if you want to automatically create a scheduled task for regular database backups.
- “Create scheduled task for FileBackup.exe (attachment backup)”
- Check this option if you want to automatically create a scheduled task for regularly backing up file attachments. The task is created without the target backup directory, which is mandatory for the “FileBackup.exe” program – the target directory must be added to the “Add arguments” field in the “Task Scheduler”, otherwise the task ends with an error.
- “Create scheduled task for Update.exe (update)”
- Check this option if you want to automatically create a scheduled task for regularly updating NET Genium to a new version.
- “Create scheduled task for ResendEmlFiles.exe”
- Check this option if you want to automatically create a scheduled task to periodically send failed emails from the “SMTP” directory.
- “Create scheduled task for RunScript.exe”
- Check this option if you want to automatically create a scheduled task to run the script with the given ID, at a specified time, or with the possibility of repeating the task regularly 2x per hour for 18 hours.
- Click the “Setup” button to start the installation. After a successful completion the program closes; it displays a message only on an error or a warning – with an MSSQL database it always warns that the user account of the created tasks should be checked.
- If a scheduled task for the same program already exists, “Setup.exe” does not change it and the new start time does not apply. In such a case the task must be modified directly in the “Task Scheduler”.
- Run the “Task Scheduler” and check the created scheduled task, or change the user account in the context of which the scheduled task should be executed.
- An additional user account change is necessary especially in situations where we plan to run a program with access to the database – “FileBackup.exe”, “Update.exe”, “ResendEmlFiles.exe” and “RunScript.exe” – and when the database server is installed on computer other than the application itself, or IIS. In this case, it is not possible to use the default user account “SYSTEM”, but typically a dedicated service account defined in “Active Directory”.
- Database backups are generally only possible from a computer that is also a database server. Therefore, it makes sense to run the “BackupServer.exe” and “SqlBackup.exe” programs only from a computer that is also a database server.