Sometimes it is needed to execute an automatic operation when a Windows user logs on. Usually some logon triggers or complex scripts are written to carry out this task. Automation Workshop effectively replaces the need for these scripts. Its built-in User Logon & Logoff Trigger detects when a user logs in or out of the system. Equipped with user-friendly interface the Trigger is easily configurable to execute its associated Task designed to perform a variety of Actions (built-in operations) or run external applications.
Get the Demo Task…
This example shows how to create a Task that will be triggered every time a user logs into the system. The Task itself will write the current date and time to a text file and then automatically open that file in the Notepad application. While the date and time will be written to a text file by the Write to File using the Date & Time variable, opening the file in the Windows Notepad application implies using the Start App Action.
Create a Task
How to create a Task? To create a Task, open Automation Workshop Manager and choose the New Task option from File menu. Alternatively, click right mouse button in Task Pane and choose the New Task option from the context menu or push Ctrl+N keyboard shortcut when Febooti Automation Workshop window is active. This will open the Task Wizard, a tool for creating and configuring Tasks.
How to add and configure User Logon & Logoff Trigger? Once in Task Wizard and acquainted with the information on Welcome page, click Next to go to the Triggers tab. Click the Add button to open the list of available Triggers. Since the Task is to be executed when a user logs in, the Trigger to choose is User Logon & Logoff. Select the User Logon & Logoff Trigger and click the OK button.
This will open Trigger properties which allow specifying the conditions for Task execution. The default option is set to execute the Task upon logon of any user which is what is needed for this Task. Other options are to execute the Task when a user logs off the system. You can also set the Trigger to monitor the system for logons or logoffs of particular users.
The Options tab of User Logon & Logoff Trigger properties allows user to specify after how much time since user logon the Task will be executed. The default option is 30 seconds that can be changed to allow the system to fully load user environment and applications before starting to perform automated Actions.
The Options tab also allows specifying how many times the user should log in before executing the Task. By default the Task is executed upon every login, but it can easily be changed to run the Task upon every second, every third, etc. login.
Click OK to save Trigger settings and notice User Logon & Logoff appearing in the Trigger list. Click Next to go to the Action section.
How to add Write to File Action? When in the Action tab of Task Wizard, click the Add button. The list of available Actions will be provided, not unlike when adding the Trigger. The first part was to write the current date and time into the file. Choose the Write to File Action in File & Folder category and click OK.
Now you must specify both the file into which the text will be written and the text itself. When specifying the file name, we can use fixed or dynamic value. If a fixed value is used, the file name will always be the same every time the Task is executed. The dynamic value, on the other hand, allows creating different files upon logons of different users. The file name specification in this case is associated with the User Logon & Logoff Trigger by using Variable Wizard.
In this example the Variable Wizard will be used to provide separate file for each user. Put a cursor into the File input line and click Browse button. Go to the necessary folder, e.g.,
C:\Logon Reports\ (create the folder if non-existent) and enter
file.txt into File name input. Click the Open button. The File input now contains
C:\Logon Reports\file.txt parameter. Select
file part of the filename and click on Variable Wizard button. This will open the Variable Wizard.
Since the filename has to match the username, choose the User Logon & Logoff in Trigger category. Choose the Username variable and click OK. Notice that instead of fixed
C:\Logon Reports\file.txt value the File input line contains
C:\Logon Reports\Username.txt where Username is a dynamic value which is always determined by the user who is logging into the system.
Now, you have to specify the text itself by adding Date & Time dynamic variable which will always return the current date and time. Put cursor into the Text to write text box and click the Variable Wizard button.
This time the value is not to be taken from User Logon & Logoff Trigger, but is provided by variables in the Date & Time category. Choose the RFC 1123 preset from Date & Time subcategory Presets and click OK to return to Write to File Action properties. Notice Date dynamic value in the Text to write input. Each time the Action will be performed, the actual date and time will be written into the text file.
Note that instead of using RFC 1123 preset which was chosen because it contains both date and time in standard international format, you can choose any other Date & Time variable (or even combine multiple components) to get the necessary Date & Time format.
The Options tab of Write to File Action allows choosing between overwriting the file each time or appending the new text to already existing file. If the Overwrite file option is chosen, each user's file will contain only the date and time of the most recent logon.
The Append at the end of file option, on the other hand, will keep the login history of each user since the implementation of automated users logon tracking. Choose the appropriate option and click OK to save Write to File Action parameters.
How to add Start App Action? The final part consists of opening the file with user login date and time in the Notepad application. Automation Workshop uses Start App Action to execute external applications. Click the Add button once more to add another Action. Choose Start App Action from Run category and click OK to enter its setup.
Click the Browse button at Program input line, locate the Notepad on disk and click OK. The Program input line now contains the path and filename of Notepad application (e.g.,
To specify which file will be opened by the Notepad application, the Arguments input must be used. Since the file name matches the user login name, there are two options. Namely, to use dynamic Username variable from User Logon & Logoff Trigger or the dynamic variable of recently written file from Write to File Action called Last file.
The latter one is preferable in case you would like to retain the Task's functionality even after changing file name in Write to File trigger later (or, for example, combining file name from dynamic Username part and some other fixed or dynamic value). Put a cursor into the Arguments input and push the Variable Wizard button. Now, select Write to File in category Actions and choose Last file variable. Click OK and notice Last file dynamic value in the Arguments input.
The Notepad application will always automatically open the file into which the date and time has been written recently. Click OK to save the Start App Action settings and return to the Task Wizard.
Click Next to go to Run As settings. Notice that the current example implies Running the Task as currently logged in user. However, in some relevant cases it can be really useful to run the Task with the credentials of some other user in parallel environment.
Click Next and configure email reports. Choose whether you want to receive email notification when the Task is finished successfully, has failed or both.
Click Next to go to the Task tab where you should give the Task a name (e.g.,
track users logon) and, optionally, description.
Continue to the Finish tab and click Finish to save and activate the Task or, alternatively, the Advanced button to review reporting, logging and other options.
While opening Notepad with logon date of current user is a rather trivial matter, Automation Workshop is by no means limited to it. Instead of Notepad, any other application can be executed in automated and highly controlled manner.
In this example it was shown how to detect user login occurrence and to process it by using Automation Workshop built-in capacities as well as external programs. The described Task monitors the system for user logins.
When any user logs into the system, the approximate login date and time (depending on how much time after login the Task is specified to start in the User Logon & Logoff Trigger) is written into a text file with the same name as currently logged user. Then this text file is automatically opened in Notepad and the Task is finished.
As a result, for each user that logs into the system there exists a text file in
C:\Logon Reports\ folder which contains all user login dates since the creation of the Task (unless the data are manually erased).
Need a helping hand?
If you have any questions, please do not hesitate to contact our support team.