-
Notifications
You must be signed in to change notification settings - Fork 53
Script: GetEnvironmentVariable
SamuelPlentz edited this page Jul 4, 2022
·
2 revisions
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
, ...
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);
}
Get environment variable USERNAME
:
[[SCRIPT=GetEnvironmentVariable|USERNAME]]
Get environment variable COMPUTERNAME
:
[[SCRIPT=GetEnvironmentVariable|COMPUTERNAME]]
Get environment variable HOMEPATH
:
[[SCRIPT=GetEnvironmentVariable|HOMEPATH]]
Get environment variable TEMP
:
[[SCRIPT=GetEnvironmentVariable|TEMP]]
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;
[[SCRIPT=GetDocumentpath]]