SiteKiosk is a secure web browser, by default it does not allow the use of WScript and similar coding options, that let you access local resources. As part of the requirements of a kiosk project you still may need to access such local resources, e.g. for querying a logged in user or reading/changing a local file or the Windows registry.
By adding an additional security layer, SiteKiosk allows you to execute such code as part of an external script file, that you need to specifically allow in the configuration of SiteKiosk. This script is started togehter with SiteKiosk. You can either execute all the required code just within the external script or you can access the script from a webpage as described in another post.
The first example just reads a registry setting and writes its value to the SiteKiosk log files:
//Wsh Shell Object
var WshShell = new ActiveXObject("WScript.Shell");
//This example reads the type of the operating system
var OsType = WshShell.RegRead("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\PROCESSOR_ARCHITECTURE");
//Write the gathered information to the SiteKiosk log file
SiteKiosk.Logfile.Notification("Detected OS type: " + OsType);
Just copy the above code into a .js file with whatever name you like and add it as an external script to test for yourself.
The second example queries the user that SiteKiosk currently runs under on the press of a button in a web page. For that we need two files. The html page, that you can put locally or on a web server, and the external script that runs the code that accesses local resources.
First is the external script that will tell us which local user SiteKiosk is running under:
//Initialize the required WScript object
var WshNetwork = new ActiveXObject("WScript.Network");
//Simple method that returns the user name
Again, just copy the above code into a .js file with whatever name you like and add it as an external script.
Next is the html code that communicates with the external script. Please have a look at this post for more information on that topic.
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<title>What user is SiteKiosk running under?</title>
//Initializing the SiteKiosk Object Model
//Query the user by using the external script file
var str_user = SiteKiosk.ScriptDispatch.QueryUser();
window.alert("User Name: " + str_user);
<input type="button" value="What user is SiteKiosk running under?" onclick="QueryUserExt()">
Copy the above code into an .html file that you name to your liking and either place it locally (e.g. in the ..\SiteKiosk\html\ folder) or on a web server. If you are not using the ..\SiteKiosk\html\ folder please make sure that the html file has script allowance in the SiteKiosk configuration.
The result of this little experiment will look similar to this:
Be aware that the code is executed with the user rights of the user you run SiteKiosk under, which may limit you options, e.g. you may only be capable of writing in the HKCU branch of the Windows registry and not in HKLM.