Script: GetEnvironmentVariable - jobisoft/quicktext GitHub Wiki
Get environment variable from the operating system. It should return the value of any variable that is defined by the operating system. For example: USERNAME
, COMPUTERNAME
, HOMEPATH
, TEMP
, ...
Script
Scriptname: GetEnvironmentVariable
let type = this.mVariables[0];
try {
var environment = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
return environment.get(type);
} catch (e) {
return("Error Ci.nsIEnvironment.get(" + type + "): " + e);
}
Usage
Get environment variable USERNAME
:
[SCRIPT=GetEnvironmentVariable](/jobisoft/quicktext/wiki/USERNAME)
Get environment variable COMPUTERNAME
:
[SCRIPT=GetEnvironmentVariable](/jobisoft/quicktext/wiki/COMPUTERNAME)
Get environment variable HOMEPATH
:
[SCRIPT=GetEnvironmentVariable](/jobisoft/quicktext/wiki/HOMEPATH)
Get environment variable TEMP
:
[SCRIPT=GetEnvironmentVariable](/jobisoft/quicktext/wiki/TEMP)
Script for variables, that depend upon the environment variables
Scriptname: GetDocumentpath
var computername = this.mQuicktext.process_script(['GetEnvironmentVariable', 'COMPUTERNAME']);
var documentpath = '';
if(computername == "computer1") documentpath = 'C:\Documents\';
if(computername == "computer2") documentpath = 'D:\Important\Documents\';
return documentpath;
Usage for variables, that depend upon the environment variables
[SCRIPT=GetDocumentpath](/jobisoft/quicktext/wiki/SCRIPT=GetDocumentpath)