Monitoring the Windows Event Log with SiteKiosk Windows

Here is a quick script based solution that describes one way to monitor the Windows event log for certain messages with the help of SiteKiosk Windows.

When you combine SiteKiosk Windows with SiteRemote the errors from the Windows application and system event logs are monitored by default. Depending on your environment you might need to monitor certain warning or even information events. There are numerous ways to achieve this in combination with SiteKiosk and the different SiteKiosk APIs. One of the simplest options is using two Javascript (JScript) files.

Two script files are required because the user you usually run SiteKiosk under does not have the rights to access the Windows event log and in order to write to the SiteKiosk logs by script (which is what we will do in this example) you need to be in the same user context as the running SiteKiosk Windows application.

The first script monitors the Windows event log for certain messages.

//This script needs to be added to the Windows Task Scheduler and set to start at system startup
//Initiating required objects
var fso = new ActiveXObject("Scripting.FileSystemObject");
var gk_locator = new ActiveXObject("WbemScripting.SWbemLocator");
var gk_wmi_service =  gk_locator.ConnectServer(".", "Root/Cimv2");

//Creating the query string
var gstr_wql = "select * from __instancecreationevent where targetinstance isa 'Win32_NTLogEvent' and targetinstance.eventcode = '102' and targetinstance.type = 'information' and targetinstance.sourcename = 'ESENT'";

//Running the query
var gk_objeventsource = gk_wmi_service.execnotificationquery(gstr_wql);

function writeToEventlogstore(message){
	var lobj_timestamp = new Date();
	
	//Make sure the path to the file matches
	var lobj_filehandle = fso.OpenTextFile("C:\\Users\\Public\\Documents\\eventlogstore.txt",8,true,-1);
	lobj_filehandle.WriteLine(lobj_timestamp + " " + message);
    lobj_filehandle.Close();
}

//Using a while loop to constantly monitor
while(true){
	//Getting a new event
	lk_objeventobject = gk_objeventsource.nextevent();
	//Check if the event contains a specific string element 
	if(lk_objeventobject.TargetInstance.Message.indexOf("starting") != -1){
		//Write to the event log store file
		writeToEventlogstore(lk_objeventobject.TargetInstance.Message);
	}
}

The script uses no SiteKiosk specific code, please use your preferred search engine if you want to learn more about the objects and methods that have been used.

This script example listens for information events (targetinstance.type = 'information') with the event ID 102 (targetinstance.eventcode = '102') and the source is ESENT (targetinstance.sourcename = 'ESENT'). It then checks for the occurrance of a specific string fragment in the message, in this case starting (lk_objeventobject.TargetInstance.Message.indexOf("starting")). Doing so, will pick a certain message from events that have the same event ID. If such a message is found, it will be written to a text file. You should place the text file at a location where the user you run SiteKiosk with has the rights to read and delete the file, e.g. C:\Users\Public\Documents\eventlogstore.txt.

Save the script as eventlogmonitor.js in the folder ..\SiteKiosk\html. Then add the script to the Task Scheduler of Windows. The script needs to run at startup with a user that is allowed to access the Windows event log. Execute it with wscript.exe.

The second script should be saved as eventlogreader.js, also in the folder ..\SiteKiosk\html, and is added to SiteKiosk as an external script by going to Start Page & Browser -> Customize -> Advanced in the SiteKiosk configuration.

//This script needs to be added to the SiteKiosk configuration as an external script 
//Initiating required objects
var fso = new ActiveXObject("Scripting.FileSystemObject");

function ReadFromEventlogstore(){
	//Make sure the path to the file matches
	var lobj_filehandle = fso.OpenTextFile("C:\\Users\\Public\\Documents\\eventlogstore.txt",1,true,-1);
	try{
		var str_eventlogstorecontent = lobj_filehandle.ReadAll();
		//Write to the SiteKiosk Logfile
		SiteKiosk.Logfile.Write(9999, 20, "CustomEventLogStore","Event log store content: " + str_eventlogstorecontent);
	}catch(e){}
	lobj_filehandle.Close();
	fso.DeleteFile("C:\\Users\\Public\\Documents\\eventlogstore.txt",true);
}

//Read the event log store every 5 seconds
SiteKiosk.Scheduler.AddPeriodicEvent(5000, ReadFromEventlogstore);

This script uses Javascript (JScript) and also the SiteKiosk Object Model and checks the text file written by the first script every 5 seconds (SiteKiosk.Scheduler.AddPeriodicEvent(5000, ReadFromEventlogstore)) while SiteKiosk is running. If the file has content it will be written to the SiteKiosk logs (SiteKiosk.Logfile.Write(9999, 20, "CustomEventLogStore","Event log store content: " + str_eventlogstorecontent)) and then the file will be deleted. Of course you also could do something different here, this is just meant as an example.

With the information added to the SiteKiosk logs you could then create a custom SiteRemote error to be notified when the event fires.

Adding Custom Components to the Software Tab of a Machine on a SiteRemote or SiteKiosk Online Server

When running your own SiteRemote or SiteKiosk Online Server you can add custom components to the software tab of a Windows machine in a team on the server. This means you can monitor the version number (must be available as a property of the file) and creation date of any executable (exe) or dynamic link library (dll) that is available on a machine. They will be shown as part of the Components table on the software tab of a machine.

By default the software tab lists the most common components and all installed software that is visible in the Programs and Features list of the Windows control panel.

If you need to monitor exe or dll files that have been copied to the machine without using a standard installation routine or that are not the main part of an application you can go to the Settings tab of the SiteRemote or SiteKiosk Online Server administration. Click on Edit configuration next to the Software component settings on the right side of the page. You will now see a table with the existing components.

Click on the Add New button to create a new entry. Choose a display name to identify the component in the table.

You can either query the component by the Component Object Model'S programmatic identifier (see https://docs.microsoft.com/en-us/windows/win32/com/-progid--key) or by the file path. You can use system environment variables as part of the file path, e.g. %windir% or %ProgramFiles%.

The Type determines under which component category the added component will be listed in the Components table on the software tab of a machine. You can select from Application, System, Additional, Remote Client or Multimedia (the other options in the dropdown field are for SiteKiosk specific usage).

Click Save on the right side of the new entry to save it temporarily, add an additional component if you wish, and then click the Save button at the bottom of the page to save the changes permanently and activate them by restarting the server service.

If the newly added component is present on a machine it will show up after a few machine contacts with the server.

Minimum User Requirements for SiteRemote Server Database Backups

When using the database backup options of the SiteRemote Server Configuration Tool the resulting job will be added to the Windows Task Scheduler. The job requires a user account, the name of which you have to state in the Server Configuration Tool (using [server name or domain name]\[user name], e.g. SRServer\Backupuser).

In order for the job to run successfully the user you choose needs a minimum set of specific rights.

If you use a local SQL database (for the SiteRemote database) and you are not using the SQL Server Management Studio for backups, the user for the SiteRemote database backup needs db_owner rights on the SiteRemote SQL database (the default name of the database is SiteRemoteBackEndServer). Note that there are no special requirements for the user regarding the Mongo DB database used for the SiteCaster part of the server.

The user also needs read and execute rights for the Data and Mongo folders and their subfolders of the SiteRemote directory (by default C:\Program Files (x86)\PROVISIO\SiteRemote\Data and C:\Program Files (x86)\PROVISIO\SiteRemote\Mongo).

Of course the user needs write rights for the backup destination folder (by default C:\Users\Public\Documents\SiteRemoteBackups).

Finally, because the job is added as a Windows task, the user needs the Windows user right to log on as a batch job.


Note that the basics described above also apply to the new SiteKiosk Online Server. Paths and names need to be adjusted.

Using SiteRemote to Install the Smart Kiosk Control Client

The Smart Kiosk Control client enables the remote control of kiosk terminals and displays with a mobile phone or tablet. The Smart Kiosk Control client can also be used for presentations or as an accessibility option. The client needs to be installed on the SiteKiosk Windows machine that a user should be able to control with a mobile device.

The installation can be done with the SiteRemote job system on existing SiteKiosk Windows machines. The SiteRemote job will consist of 3 steps.

Download the RemoteInput installer from your SiteRemote team account at Administration -> Downloads or directly here: https://www.siteremote.net/download/SmartKioskControlSetup.exe.

Next go to SiteKiosk -> Jobs in your SiteRemote team and click on the New Job button. Give the job a name, e.g. Install Smart Kiosk Control Client. You may also check the option to Save this job as a new template, if you want to reuse it in the future. Add a description if desired. 

Now choose File Upload from the available tasks to create the first job step. Upload the downloaded file and choose the destination path, e.g. %TEMP%\SmartKioskControlSetup.exe.

For the second step choose the task Run Executable. For the command line use

%TEMP%\SmartKioskControlSetup.exe /exenoui /qn

This will start a silent installation of the application. Make sure to choose invisible execution, so the installer runs with administrative rights.

The third and final step uses the Execute Operating System Command task. Use Restart from the available options. This will restart the operating system to finish the installation process.

Assuming the SiteKiosk machine is set to Autostart mode, a user will be able to remotely control SiteKiosk with a mobile device after the restart.

The Powerful Run Executable Job Action Type of SiteRemote

An often overlooked action type of the SiteRemote job system (in your SiteRemote team choose SiteKiosk from the menu and then select the job tab) is one called Run Executable. It is a more general action type than most of the others but that is what makes it so powerful. What it allows you to do is to basically run any executable including the use of parameters.  

 

You can run Windows Powershell, batch files, (silent) installers, Windows system tools and so on. This allows you to administrate your SiteKiosk Windows machines in almost every possible way in addition to the SiteKiosk administration and monitoring the SiteRemote GUI already helps you with.

It is even possible to update SiteKiosk remotely with the help of the Run Executable job action type. Please contact our support for more information, because the exact method varies based on the SiteKiosk version in use.

This job action type runs on the client invisible with administrative privileges in the context of the Local System user or visible with the rights of the user that is logged in at the moment the job is executed.

If the executable you run provides a return value you can use that to show whether the job was successful or not on the SiteRemote job page. Not using this option will show the job as successful if starting the executable did not return an error.

A simple example that starts Notepad with the SiteKiosk license text would be this command line:

"c:\windows\notepad.exe" "c:\program files (x86)\SiteKiosk\license-en.txt"

If you then choose the option Visible execution with user rights, the job will start Notepad with the license text file on the SiteKiosk Windows machine, once the job has been assigned and ececuted on a client.

Please note that past DevBlog posts have described how to access 64-Bit system folders and registry paths (https://devblog.provisio.com/post/2015/11/03/Accessing-64-Bit-System-Folders-and-Registry-from-the-SiteRemote-Job-System.aspx) or how to unzip zip archives uploaded with a SiteRemote job step to a specific destination folder (https://devblog.provisio.com/post/2016/02/22/Distributing-the-SiteKiosk-Windows-Start-Screen-with-SiteRemote.aspx) all with the help of the Run Executable job action type.

Create a new project template from an existing project

It is possible to make existing SiteCaster projects in SiteCaster permanently available again as templates. This entry describes how to create a template from an existing project if you have an own server.

First you have to export the corresponding project:

1. Open the project in the editor and copy the project ID from the URL.

for example:

https://www.siteremote.net/sitecastercms/editor/assets/index.html#app-editor?projectId=5e7b5098415fcafc08348a01&variantId=5e7b5098415fcafc08348a03

2. Insert the project ID in the following line.

3. https://www.siteremote.net/sitecastercms/api/projects/5e7b5098415fcafc08348a01/export

4. Copy the URL

5. Open a new tab and paste the created export address – press Enter

6. Press Enter to download the zip file 

In the second part you have to modify the project folder and transfer it to a template folder:

1. Unpack the zip file.

2. Rename the content.json file located in the folder to content.original.json

3. Go to the following directory on the server:

C:\Program Files (x86)\PROVISIO\SiteRemote\Web.SiteCaster\server\projects\projectTemplates

4. Copy one of the existing template folders and paste it again.

5. Rename the folder (e.g. name of the template).

6. Replace the image file in the folder with an image file of your template, whereby the name preview must be retained and the file type has to be JPG.

7. Open the projectTemplate.manifest file in the folder with a text editor (e.g. Notepad)

8. Change the name of the template "name": "${string:StartScreenTemplate.name}", e.g. to "name": "TEST-Template”

9. Change the Project ID "projectID": "311f9e4eb2427f5ec02e32f1" in the file to create a unique new ID e.g. "projectID": "777f9e4eb2427f5ec02e32f1

10. Open the folder: 00000000000000000000

11. Delete the content of the folder

12. Add the complete content of the zip folder with the content.original.json file into the 00000000000000000000000000 folder

13. Open the SiteCaster Editor in a browser and click on the Create New Project button -> The new project template is now available

If you want to offer your template on your server in a team-specific manner, you must use the following path for the procedure described above:

C:\Program Files (x86)\SiteRemote\Common\Teams\teamStorage\<TeamId>\projectTemplates

The team ID specified in the path is individual per team and can be found on the server administration page in the tab teams.

Using tags to display variants of a SiteCaster project on different machines

If you want to display variants of a SiteCaster project that differ only in a few elements, you can use the tag feature in SiteCaster as a display condition.

In the following example, a SiteCaster project is published on two machines to display two variants of a project:

Log into your SiteRemote team and select the Monitoring tab. To generate tags for your machines, right click on a machine in the tree view and select Assign Tags.

 

Then enter the name of your tags e.g. Terminal 1 and Terminal 2 press Add and select it using the checkbox. Confirm the setting with Save.In SiteCaster, generate your sample project using the empty template. Use the Add button to add a swap container to the project. Insert two different images into the swap container. In order to use the Tag display condition, you will need to enable the expert mode in SiteCaster. To do so, you need to insert &expert at the end of the URL in the URL address field of your browser and then press Enter to reload the project. 

After activation of the expert mode you see the Expert Edit button in the tool bar.  

Then select one of the images and open the properties dialog by double-clicking on the image. Go to the section Display condition and select the Display under these conditions option. Activate the check box Tag and enter the tag name Terminal 1. Close the properties dialog with pressing the Save button. Activate the same setting on the other image with the tag name Terminal 2. After publishing the project to both clients the first image is displayed on the device with the tag Terminal 1 and the second image on the device with the tag Terminal 2. The described scenario can be extended with further tags as you like.   

How to Encrypt SiteRemote Server to SQL Server Connections

If you want to encrypt the connection between your SiteRemote Server and the Microsoft SQL Server hosting the database for SiteRemote, especially when using a remote Microsoft SQL Server, you can just enable forced encryption in the settings of your Microsoft SQL Server. This enables basic encryption between the two servers. To learn how you can enable encryption for your Microsoft SQL Server please refer to the documentation of the SQL Server provided by Microsoft.

The above enables encryption but does not protect from man-in-the-middle attacks on the connection. If you need this additional layer of security, configure your Microsoft SQL Server to use a certificate and make sure the machine running the SiteRemote Server trusts the certificate. Please refer to the SQL Server documentation provided by Microsoft for the SQL Server version you are using to configure this setup. Once this is done, you need to change the connection string used by SiteRemote to connect to the SQL Server. Note that this change can only be done after SiteRemote has been installed.

Open the file ..\PROVISIO\SiteRemote\Config\SiteRemoteServer.config from your SiteRemote installation folder with an editor and look for lines similar to this example:

<ConnectionStrings>
	<Add Name="default" Encrypted="true">
		<ConnectionString>Data Source=sql.server;Initial Catalog=SiteRemoteBackEndServer;User ID=sa;Password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</ConnectionString>
	</Add>
</ConnectionStrings>

You need to add encrypt=true and trustServerCertificate=false (true would not validate the certificate) to the connection string. The above example would look like this with the additional settings added:

<ConnectionStrings>
	<Add Name="default" Encrypted="true">
		<ConnectionString>Data Source=sql.server;encrypt=true;trustServerCertificate=false;Initial Catalog=SiteRemoteBackEndServer;User ID=sa;Password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</ConnectionString>
	</Add>
</ConnectionStrings>

Limiting the Color Mode for VNC Connections

Please note that the following text is an updated version of this older post. The update applies to SiteRemote 5.1 and above (including version 6.1, which is the current version at the time of writing this post).

SiteRemote uses the auto mode to set the colors for the VNC session. This usually provides the best experience. You may like or need to limit the color mode to 256 colors only when establishing the connection, mainly because of poor connection speed.

To switch from auto mode to 256 colors you need to edit a file on the PC you are establishing the connection from. On this PC you have installed the UVNC client for SiteRemote, it is usually located in the path C:\Program Files (x86)\PROVISIO\VncViewer\. There you can find the file options.vnc. Please open the file with an editor like Notepad. You will see that there is not much in it:

[connection]
index=

These lines need to be added to the file:

[options]
autoDetect=0
QuickOption=0

The complete file should now look like this:

[connection]
index=
[options]
autoDetect=0
QuickOption=0

Save the file under its original name. Next you need to right-click the file, choose Options -> Security and give the default Windows Users group read and write access to the file.

When you now start your next VNC session it will default to just 256 colors, therefore speeding up the view on a slow Internet connection.

Note that independent from this change you can always edit the options of a running VNC connection by clicking the Options button in the upper toolbar of the VNC window. This allows you to make one-time changes to the current connection.

Using the Expert Mode of the SiteCaster Editor

The SiteCaster Editor comes with an expert mode, that allows you to edit settings beyond their default value range. This gives you the opportunity to customize your projects to match very specific requirements. Feel free to experiment with this mode, but be aware that changing values beyond their default range is outside of the scope of our free support.

To enter the expert mode open a project to view the project page. Now click the address bar of your browser and append &expert to the URL. Make sure you place it at the very end of the URL and then press enter to open the expert mode.

Next select the element you want to customize. In our example we want to adjust the font size and the font family of the Time/Date element. To do that, click on the new advanced edit button you will see in the toolbar after entering the expert mode.

After clicking the button you will see a list of all properties of the selected element in the inspector. In the list you will find the dateFontFamily and dateFontSize properties. Use the drop-down of the dateFontFamily property to select String and type in the font family of your liking into the text field. For the dateFontSize property select Number from the dropdown and then type in the pixel value you want to choose. Click on the Save button after you are done to apply the changed values.

To give you an idea of the advanced possibilities you get from choosing the expert mode here is a view of the default options you have for the Time/Date element.

 As you can see the default element will cover the needs of most users but when using the expert mode you can change the properties to whatever you like.