Returns the cost flags for a connection to the specified host. See https://msdn.microsoft.com/de-de/library/windows/desktop/hh437608(v=vs.85).aspx for a definition of WCM_CONNECTION_COST flags
var logLevel = gkScript.getLogLevel() // gets current LogLevel
gkScript.setLogLevel(ll_ERROR) // sets the LogLevel to Error
gkScript.logError(string) // Log an error message
gkScript.logInfo(string) // Log an info
gkScript.logDebug(string) // Log a debug string
bool gkScript.exportLog(string path) // Export the log to a file
Tray Icon
gkScript offers the following functions to control the tray icon (client.exe only):
class callbackObject
{
void onTrayClick();
}
bool showTrayIcon(callbackObject);
hideTrayIcon();
WMI
Script
Function
gkScript::wmiQuery(Path, Query)
Executes WMI queries.
Path is the object path of the WMI namespace to query, e.g. ROOT\CIMV2Query is the WQL query to execute.
The following code is a WMI query sample:
def printResults(wmi) {
var count = 0;
for (i:wmi) {
print (" Item " + to_string(count));
++count;
for (j:i) {
if (j.first[0] == '_') {continue;}
if (is_var_undef(j.second)) {print(" " + j.first + ": undefined");}
else{print(" " + j.first + ": " + to_string(j.second));}
}
}
}
print("Win32_DiskDrive");
var r=gkScript.wmiQuery("ROOT\\CIMV2", "SELECT Manufacturer, Model, Size FROM Win32_DiskDrive where Size>0");
printResults(r);
Script Tool
The scriptTool class is a sandbox for ChaiScripts. You can call scripts without messing up your own environment...
Script
Function
gkScript.ScriptTool(true)
gkScript object inside the sandbox
gkScript.ScriptTool(false)
Creates a sandbox without gkScript object
{
} ScriptTool instances do not have an exit() command {}
class ScriptTool
{
bool addScript(string script);
object callFunction(string func);
void reset(); // delete all defined variables and functions
};
The following code is a ScriptTool sample:
eval> var script=gkScript.ScriptTool(true);
eval> script.callFunction("gkScript.getVersion()");
0.2.0.0
eval> script.addScript("def testFunction(val) {return \"testFunction - \" + val;}");
true
eval> script.callFunction("testFunction(\"hello world\")");
testFunction - hello world
eval> script.reset();
eval> script.callFunction("testFunction(\"hello world\")");
[2017-12-01 18:26:11.946] [1668] [error] [Default] ScriptTool::callFunction: Eval exception thrown: Error: "Can not find object: test" during evaluation at (__EVAL__ 1, 1)
eval>