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.

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