LogoLogo
LogoLogo
  • Welcome
  • Introduction
  • Beginning
    • Server Configuration
    • Sidebar
    • Binaries
  • Client Executables
    • client.exe
    • chaiCmd.exe
    • rmService.exe
  • Modules
    • Module Configuration
    • Inventory
    • File
    • PST
    • Custom
    • Server
    • Folder Lists
    • Own Blob Storage
  • Groups
    • Groups General Overview
    • Groups Configurations
  • Clients Menu
    • Overview
    • Client Information
    • Module Information
  • Reporting
    • Reporting
    • Customize Reports
  • Recipes
    • Group based actions
    • Time based actions
    • Set bandwidth
    • Dump Config
    • Remove PSTs
    • Server Module Scripting
    • Self Service
  • ChaiScript Reference
    • ChaiScript Overview
    • GK Script Object Reference
      • Module Reference
      • HTTP Reference
      • Web Browser
      • File System
      • Graph Reference
      • MS Graph Authentication
      • Hash Reference
      • Registry Reference
      • COM
      • Self Update Reference
Powered by GitBook
On this page

Was this helpful?

  1. ChaiScript Reference
  2. GK Script Object Reference

Self Update Reference

Installation

gkScript methods:

  • Install itself to the machine and set an auto-run key to start on every logon.

  • Self-update an installed client.

gkScript also ensures that the installed client is running as a single instance per logon session.

Script
Function

string gkScript::getVersion()

Version string of the current client-xxx.exe / chaiCmd-xxx.exe module

string gkScript::moduleFilename(bool fullPath = false)

Module file name of the current client-xxx.exe / chaiCmd-xxx.exe module.

int gkScript::getPID()

Process ID of the current instance.

bool gkScript::isInstalled()

- Returns false for chaiCmd-xxx.exe - Returns true if client-xxx.exe is present in the target path

bool gkScript::isInstalledInstance()

- Returns false for chaiCmd-xxx.exe - Returns true if client-xxx.exe was started from install-path

bool gkScript::setupClient(bool install)

- Will install itself or deinstall the client - Will fail if current module is chaiCmd-xxx.exe - Will fail of isInstalledInstance() == true

string gkScript::installPath()

Returns the installation path

Sample install code:

def checkInstallation(serverVersion, app) {
    if (gkScript.isInstalledInstance()) {
        gkScript.logDebug("we are the installed client, checking auto-update ...");

        if (gkScript.getVersion() != serverVersion) {
        var path = gkScript.expandString("%temp%\\" + gkScript.moduleFilename());
            if (app.loadClient(path)) {
                gkScript.logDebug("starting new client for self-update ...");
                gkScript.runProcess(path);

                exit(0);
            }
            else {
                gkScript.logError("Failed to load: " + path);

                exit(2);   // comment this line if the outdated version should run as fallback..
            }
        }
        return true;
    }
    else {
        if (gkScript.isClientInstalled()) {
            gkScript.logDebug("Client is installed, nothing to do.");
            exit (0);
        }
        else {
		    if ("chaicmd" == gkScript.toLower(gkScript.moduleFileName().substr(0,7))) {
                gkScript.logDebug("Running chaiCmd with bootstrapper.");
				return true;
			}

            gkScript.sleep(10000);  // wait for main process to end.
            if (!gkScript.installClient()) {
                gkScript.logDebug("Failed to install client!");
                exit(2);
            }
        }
    }

    gkScript.logDebug("starting new client for self-update ...");
    gkScript.runProcess(gkScript.installPath() + gkScript.moduleFilename());

    exit (0);
}

Last updated 1 year ago

Was this helpful?