Skip to main content

module @env

The module represents current OS and running environment.

constants:

  • env.OS - OS identification name, for example "Windows-8.1"
  • env.PLATFORM - OS/platform generic name: "Windows", "OSX", "Linux", "Android", etc.
  • env.DEVICE - device type: "desktop", "mobile"

functions:

env.language()

Returns two-letter language abbreviation of user's default language, for example "en" for English.

env.country()

Returns two-letter country abbreviation, for example "CA" for Canada.

env.userName()

Returns current user name.

env.machineName()

Machine network name.

env.domainName()

Machine network domain.

env.arguments()

Returns array of command line arguments.

env.launch(path)

Method to open documents and start applications;

Example: env.launch("https://sciter.com") will open default browser with that url.

env.home([relpath]): string

Converts relative path to absolute path using location of sciter.dll as a base.

env.homeURL([relpath]): string

Same as env.home(relpath) but returns "file://..." URL.

env.path(name,[relpath]): string

Returns location of well known folders on user machine, name is one of:

  • "home" - user's home folder;
  • "applications" - applications a.k.a program files;
  • "root" - file system root;
  • "desktop" - desktop folder;
  • "appdata" - applications data folder;
  • "downloads"
  • "documents"
  • "music"
  • "videos"
  • "pictures"

If relpath is provided the function returns absolute path of that relpath combined with the folder path.

env.drives() : []

Returns list of paths - root paths of mounted drives.

const drives = env.drives();
// drives: ["C:","D:"] on Windows

env.pathURL(name): string

same as env.path(name) but returns "file://..." URL.

env.variable(name:string [,toset:string | null]): string

getenv/setenv(,,true)/unsetenv() ( if toset is null )

env.exec()

execute comma-separated arguments. Example: exec("scapp.exe", "main.html")