> ## Documentation Index
> Fetch the complete documentation index at: https://docs.directgvr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Host JavaScript

> Reference for the JavaScript interfaces the DirectGVR host exposes to skins.

## Overview

This document covers most of the functions made available by the Host application.

**String Arguments**

The string arguments for any of the functions below should be UTF-8 encoded.

## JavaScript helpers

Simple javascript helpers.

### extend

**Version:**  5.1.10

Equivalent to jQuery extend function.

### extractFromSkinFile

Extracts a file from the skin to disk.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to the skin file |
| outputPath | string | Path to save on disk |
| completeCallback | function | Callback function when complete |

**Return Value:**

True if successful, false otherwise.

### hashFile

Hashes a file using a specific algorithm and returns the digest.

**Version:**  7.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| algorithm | string | Algorithm to use when hashing. Supported algorithms: crc, md5, sha1, sha224, sha256, sha384, sha512 |
| path | string | Path of the file to hash. |
| completeCallback | function | JavaScript function to call when done hashing |

**Return Value:**

Complete callback is always called and passes the digest and the successful result to the complete callback.

**Changes:**

* 7.0 - Removed MD2 and MD4 hash algorithms

**Example:**

```javascript theme={null}
hashFile("md5", "any.txt", (digest, successful) => {
  console.log(`hash: ${digest} ${successful}`);
});
```

### isNull

Checks to see if a value is null or undefined

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| obj | object | Object to check |

**Return Value:**

True if null, undefined or a blank jQuery selector, false otherwise.

**Example:**

```javascript theme={null}
var val = null;
if (isNull(val)) {
    console.log("Val is null");
}
```

### readJSONFromFile

Reads a text from a file and parse it into JSON object.

**Version:**  5.1.7

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the text file to read |
| completeCallback | function | JavaScript function to call when done reading |

**Return Value:**

Complete callback is always called and if successful passes the JSON object to the complete callback, otherwise passes null.

### readJSONFromSkinFile

Reads a text from a file in the skin and parse it into JSON object.

**Version:**  5.1.10

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | integer | Path of the text file to read |
| completeCallback | function | JavaScript function to call when done reading |

**Return Value:**

Complete callback is always called and if successful passes the JSON object to the complete callback, otherwise passes null.

### readTextFromFile

Read text from a file.

**Version:**  5.1.7

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | integer | Path of the text file to read |
| completeCallback | function | JavaScript function to call when done reading |

Complete callback is always called and if successful passes the string to the complete callback, otherwise passes null.

### readTextFromSkinFile

Read text file from the skin.

**Version:**  5.1.10

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | integer | Path of the text file to read |
| completeCallback | function | JavaScript function to call when done reading |

Complete callback is always called and if successful passes the string to the complete callback, otherwise passes null.

### thisIs

Checks if a bit value is on.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | Value to compare |
| y | integer | Bit to check |

**Return Value:**

True if the bit is set, otherwise false.

**Example:**

```javascript theme={null}
var permissions = platformAccessPermissions.READ | platformAccessPermissions.WRITE;
if (thisIs(permissions, platformAccessPermissions.READ)) {
    console.log("Has read access");
}
if (thisIs(permissions, platformAccessPermissions.WRITE)) {
    console.log("Has write access");
}
```

### thisIsNot

Checks if a bit value is off.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | Value to compare |
| y | integer | Bit to check |

**Return Value:**

True if the bit is not set, otherwise false.

**Example:**

```javascript theme={null}
var permissions = platformAccessPermissions.WRITE;
if (thisIsNot(permissions, platformAccessPermissions.READ)) {
    console.log("Doesn't have read access");
}
if (thisIsNot(permissions, platformAccessPermissions.WRITE)) {
    console.log("Doesn't have write access");
}
```

### turnOff

Turns a bit value off.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | int | Value |
| y | int | Bit to turn off |

**Return Value:**

Returns the value with the bit turned off.

**Example:**

```javascript theme={null}
var permissions = platformAccessPermissions.READ | platformAccessPermissions.WRITE;
turnOff(permissions, platformAccessPermissions.WRITE);
// permissions = platformAccessPermissions.READ;
```

### turnOn

Turns a bit value on.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | Value |
| y | integer | Bit to turn on |

**Return Value:**

Returns the value with the bit turned on.

**Example:**

```javascript theme={null}
var permissions = platformAccessPermissions.READ;
turnOn(permissions, platformAccessPermissions.WRITE);
// permissions = platformAccessPermissions.READ | platformAccessPermissions.WRITE;
```

### writeJSONToFile

Writes JSON to a file.

**Version:**  5.1.7

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the text file to read |
| obj | object | JSON object |
| spaces | integer | Spaces to use for pretty formatting |

**Return Value:**

True if successful, false otherwise.

**Changes in 5.2:**

* Added spaces argument

### writeTextToFile

Writes text to a file.

**Version:**  5.1.7

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the text file to read |
| text | string | Text to write |

**Return Value:**

True if successful, false otherwise.

## Analytics

Analytics functions.

### extend

Sends additional data along with all analytics events.

**Version:**  5.1.10

**Arguments:**

| Name | Type | Description |
| - | - | - |
| info | object | JSON data to send |

**Example:**

```javascript theme={null}
analytics.extend({ "systemName": "{systemShortName}" });
```

### sendEvent

Queues an analytics event for sending. Analytics events are queued and sent on an interval defined in the application configuration's *analytics.sendInterval*  property. If there are events left to be sent when the application shuts down they will be sent before the application closes.

**Version:**  5.1.8

**Arguments:**

| Name | Type | Description |
| - | - | - |
| eventName | string | Name of the event |
| info | object | JSON data to send |

**Return Value:**

True if successful, false otherwise.

**Example:**

```javascript theme={null}
analytics.sendEvent("UserSignedIn", { "emailAddress": "x@x.com" });
```

### setEnabled

Sets whether or not analytics is enabled.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| enabled | boolean | If *true* , analytics won't be sent, *false* otherwise. |

**Return Value:**

True if successful, false otherwise.

**Notes:**

* To disable sending of analytics this should be called before any send interval occurs.

### setEndpoint

Sets the endpoint for sending analytics events.

**Version:**  7.2.46

**Arguments:**

| Name | Type | Description |
| - | - | - |
| endpoint | string | Analytics server url |

**Return Value:**

True if successful, false otherwise.

### setKey

Sets analytics api key.

**Version:**  7.2.29

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | API key. |

**Return Value:**

True if successful, false otherwise.

## App (SkinApp)

High level host application functions.

### closeAllWindows

Closes all the application windows.

**Version:**  3.6

**Return Value:**

True if successful, false otherwise.

### contentExists

Gets whether or not a content exists in the app bundle.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path relative to the app bundle root |

**Return Value:**

True if content exists, false otherwise.

**Example:**

```javascript theme={null}
let firstLocale = null;
["en", "de", "fr", "ru"].every(locale => {
   if (skinApp.contentExists(`locale/${locale}.md`)) {
      firstLocale = locale;
      return false;
   }
   return true;
});
```

### expandString

Same as *workflowApp.expandString* except that *\{contentUrl}*  macro is expected using the *--devserver*  argument first. This is useful during development in instances where you want to get the url to the devserver if it is available, but to otherwise fallback to the internal web server when *--devserver*  is not available.

**Version:**  6.1

### getCountry

Gets the locale country set for the application in ISO 3166 format.

**Version:**  3.6

### getDataStore

Gets the base-64 encoded authenticated datastore for the current application.

**Version:**  6.1.0.96

**Example:**

```javascript theme={null}
var base64DataStore = skinApp.getDataStore();
var dataStore = atob(base64DataStore);
```

### getLanguage

Gets the locale language in set for the application in ISO 639 format.

**Version:**  3.6

### getRemoveLocalStorage

Gets whether or not the flag to remove the local storage on shutdown is set.

**Version:**  3.6

### isAttached

Gets whether or not a skin is attached to the current executable.

**Version:**  6.1.0.96.

### isMainWindow

Gets whether or not the skin window is the main window.

**Version:**  5.2.033.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| instanceId | string | instance id of the window |

**Return Value:**

Returns true if the window is the main window, false otherwise.

### localizeString

Localizes a string in the current language. It is not recommended to call this function for each locale string as it can impact performance negatively. Instead independently load the localization files in JavaScript using XMLHttpRequest.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| stringId | string | ID of the string to localize |

**Return Value:**

Returns the localized string, otherwise it returns stringId.

### openWindow

Opens a new top level skin window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| windowConfigPath | string | Path of the window's config JSON relative to the skin directory. |

**Return Value:**

Returns the instance id of the new window if successful, null otherwise.

### setCountry

Sets the locale country for the application in ISO 3166 format.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| country | string | Country to set |

**Return Value:**

True if successful, false otherwise.

### setLanguage

Sets the locale language for the application in ISO 639 format.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| language | string | Language to set |

**Return Value:**

True if successful, false otherwise.

### setRemoveLocalStorage

Sets whether or not to remove the local storage directory on shutdown.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| removeLocalStorage | boolean | If true, remove local storage on shutdown, false otherwise. |

**Return Value:**

True if successful, false otherwise.

## App (WorkflowApp)

Lower-level host application functions.

### addMacro

Adds a macro to the application's macro table.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | Macro key |
| value | string | Macro value |

**Return Value:**

True if successful, false otherwise.

**Example:**

```javascript theme={null}
app.addMacro("MyMacro", "MyValue");
var val = app.expandString("123{MyMacro}123");
// val = "123MyValue123;
```

### convertFromEntitizedString

Converts an a string with HTML entitized Unicode characters into their UTF-8 equivalent.

**Version:**  3.4

**Arguments:**

| Name | Type | Description |
| - | - | - |
| htmlstring | string | HTML entitized string |

**Return Value:**

Returns an UTF-8 string.

### convertToEntitizedString

Converts a string containing Unicode characters that are UTF-8 encoded into their HTML entitized equivalent.

**Version:**  3.4

**Arguments:**

| Name | Type | Description |
| - | - | - |
| utf8string | string | UTF-8 string |

**Return Value:**

Returns an HTML entitized string.

### crash

Crashes the application. Used for testing crash reporting.

**Version:**  3.6

### debugPrint

Prints a line to the debug log.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| text | string | Text to print to debug log |

**Example:**

```javascript theme={null}
app.debugPrint("This should show in the debug log");
```

### expandString

Expands the string with the current applications macros.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| any | string/object/list | String, object, or list to expand |
| defaultValue | any | Default value if not expanded. If first argument is an object or list, and the default value is *null* , any unexpanded strings will not be added to the object or list. |

**Return Value:**

Returns the expanded string.

**Changes:**

* 6.1 - Added defaultValue argument
* 6.1 - Added support for objects and lists

**Example:**

```javascript theme={null}
var desktopPath = app.expandString("{userDesktop}");
// desktopPath = c:\users\username\desktop\
```

### getCommandFieldCount

Gets the number of arguments in a command line.

**Version:**  6.1

**Example:**

```javascript theme={null}
// command line: --hello
if (app.getCommandFieldCount() == 1) {
    console.log("one argument set!");
}
```

### getCommandField

Gets the value for a command field by its index.

**Version:**  6.1

**Example:**

```javascript theme={null}
// command line: --hello
if (app.getCommandField(1) == "--hello") {
    console.log("hello is set!");
}
```

### getCommandFieldByName

Gets the value for a command field by its name (case-insensitive).

**Version:**  3.6

**Example:**

```javascript theme={null}
// command line: --hello="world"
if (app.getCommandFieldByName("hello") == "world") {
    console.log("hello world is set!");
}
```

**Notes:**

* This function is NOT intended for use with command line (flags) parameters that contain no value.

### getCommandLine

Gets the command line string for the application.

**Version:**  3.6

### getConfig

Retrieves a config setting given its key.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | Config key |
| defaultValue | string | Default value if not found |

**Return Value:**

Returns the value for the configuration key.

**Example:**

```javascript theme={null}
var skinName = app.getConfig("skinName")
// skinName = "launcher";
```

### getCurrentTime

Gets the seconds.milliseconds since computer started.

**Version:**  3.6

### getDebugFilename

Gets the path of the debug log.

**Version:**  3.6

### getDebugFlags

Gets the debug flags set.

**Version:**  3.6

### getExitCode

Gets the exit code set for the application when it exits.

**Version:**  5.1

### getPreventSystemShutdown

Gets whether or not to prevent system shutdown while tasks are active. Not applicable if cef.enabled set to true.

**Version:**  5.2

### getRestart

Gets whether or not the flag to restart is set.

**Version:**  3.6 (previously *skinApp.getRestart* )

### getRestartArguments

Gets the command line arguments string used for restarting the application.

**Version:**  3.6 (previously *getRestartCommandLine* )

### getRestartElevated

Gets whether or not the flag to restart elevated is set.

**Version:**  3.6 (previously *skinApp.getRestartElevated* )

### getRestartPath

Gets the path to the executable to launch when restarting.

**Version:**  6.1 (previously part of *getRestartCommandLine* )

### getRunningTime

Gets the seconds.milliseconds the application has been running.

**Version:**  3.6

### getSecurityEnabled

Gets whether or security is enabled.

**Version:**  3.6

### getStartTime

Gets the seconds.milliseconds since the computer started at application start.

**Version:**  3.6

### implode

Sets a flag to self-delete the executable after exiting.

**Version:**  3.6

### isCommandFieldSet

Checks to see if a command flag is set on the command line.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| commandField | string | Name of the field (case-insensitive) |

**Return Value:**

True if the command flag if it is set, false otherwise.

**Notes:**

* This function is ONLY intended for use with command line (flags) parameters that contain no value.

**Example:**

```javascript theme={null}
// command line: --debugThis
if (app.isCommandFieldSet("debugThis")) {
    console.log("debugThis is set!");
}
```

### isElevated

Gets whether or not the application is elevated.

**Version:**  5.1

### jwsVerifyCertStore

Verifies a JSON web signature that has been signed with a certificate.

**Version:**  6.1 (*jwsVerifyX509*  in 5.2)

**Arguments:**

| Name | Type | Description |
| - | - | - |
| signature | string | JSON web signature |
| store | string | Comma delimited list of valid certificate stores (empty string for platform store) Predefined certificate stores: platform: System certificate store null: Empty certificate store |

**Return Value:**

True if verified successfully, false otherwise.

### jwsVerifyKey

Verifies a JSON web signature that has been signed with a secret key.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| signature | string | JSON web signature |
| key | string | Base64 encoded value of the secret key |

**Return Value:**

True if verified successfully, false otherwise.

### jwsVerifyKeyStore

Verifies a JSON web signature against a key in the key store.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| signature | string | JSON web signature |
| store | string | Name of the key in the key store |

**Return Value:**

True if verified successfully, false otherwise.

### loadInterop

Loads an interop.

**Version:**  3.6, 5.1.9

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Friendly name of the interop |
| path | string | Path to the interop library |

**Return Value:**

Fires a notification when complete. The name value is sent to the notification.

### setExitCode

Sets the exit code for the application when it exits.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| exitCode | integer | Exit code |

**Return Value:**

True if successful, false otherwise.

### setPreventSystemShutdown

Sets whether or not to prevent system shutdown while tasks are active.

**Version:**  5.2

### setRestart

Sets whether or not to restart the application after shutting down.

**Version:**  3.6 (previously *skinApp.setRestart* )

**Arguments:**

| Name | Type | Description |
| - | - | - |
| restart | boolean | If true will restart the app on shutdown, false otherwise. |

**Return Value:**

True if successful, false otherwise.

### setRestartArguments

Sets the command line arguments string for restarting the application.

**Version:**  6.1, 3.6 (previously *setRestartCommandLine*  or *setCommandLine* )

**Arguments:**

| Name | Type | Description |
| - | - | - |
| restartArguments | string | Command line arguments string |

**Return Value:**

True if successful, false otherwise.

### setRestartElevated

Sets whether or not to restarted the application elevated upon after shutting down.

**Version:**  3.6 (previously *skinApp.setRestartElevated* )

**Arguments:**

| Name | Type | Description |
| - | - | - |
| restartElevated | boolean | If true, will restart the app on shutdown elevated, false otherwise. |

**Return Value:**

True if successful, false otherwise.

### setRestartPath

Sets the path to the executable to use when restarting the application.

**Version:**  6.1 (previously part of *setRestartCommandLine* )

**Arguments:**

| Name | Type | Description |
| - | - | - |
| restartPath | string | Path to executable for restarting |

**Return Value:**

True if successful, false otherwise.

### unloadInterop

Unloads an interop.

**Version:**  3.6, 5.1.9

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Friendly name of the interop |
| path | string | Path to the interop library |

**Return Value:**

Fires a notification when complete. The name value is sent to the notification.

## AppDebugFlags (WorkflowAppDebugFlags)

Debug flags enumeration.

| Name | Description |
| - | - |
| DISABLED | Disabled |
| WINDOW | Show console window |
| FILE | Write to debug file |
| APPEND | Append to previous debug logs on start |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |
| separator | string | Optional string separator |

## AppNotificationDock (WorkflowAppNotificationDock)

Notification dock flags enumeration.

| Name | Description |
| - | - |
| LEFT | Dock left |
| RIGHT | Dock right |
| TOP | Dock top |
| BOTTOM | Dock bottom |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |
| separator | string | Optional string separator |

## DirectorySize

Calculates directory allocated size on the disk.

### createDirectorySize

Creates a new DirectorySize object.

**Version:**  7.0

**Example:**

```javascript theme={null}
var directoryGetSize = function(path, completeCallback) {
    var observers = [];
    var directorySize = createDirectorySize();
    directorySize.setPath(path);
    observers.push(notificationCenter.addInstanceObserver("DirectorySize", "Complete", directorySize, function(sender, info) {
        observers.forEach(function(observer) {
            observer.release();
        });
        directorySize.release();
        if (!isNull(completeCallback)) {
            completeCallback(info.size, info.successful);
        }
    }));
    directorySize.start();
};
```

### getPath

Gets the directory path.

**Version:**  7.0

### release

Releases the instance.

**Version:**  7.0

### setPath

Sets the directory path.

**Version:**  7.0

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |

**Return Value:**

True if successful, false otherwise.

### start

Starts calculating the size.

**Version:**  7.0

### stop

Interrupts calculating the size.

**Version:**  7.0

## FileSystem

File system functions.

### directoryCreate

Creates a directory.

**Version:**  5.1, 3.6 as *platform.directoryCreate*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |

**Return Value:**

Returns 0 if the path was created, OS error code otherwise.

**Example:**

```javascript theme={null}
var pathToCreate = app.expandString("{pathJoin:{temp},{guid}}");
var wasCreated = fileSystem.directoryCreate(pathToCreate);
if (wasCreated) {
    console.log("Path created successfully - {0}".format(pathToCreate));
}
```

### directoryErase

Removes a directory.

**Version:**  5.1, 3.6 as *platform.directoryErase*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |

**Return Value:**

Returns 0 if the path was removed or doesn't exist, OS error code otherwise.

**Warning:**

* This function is a blocking call and long running operations can block the UI.
* Alternatively, use the directoryErase task.

**Example:**

```javascript theme={null}
var pathToErase = app.expandString("{pathJoin:{userDesktop},xyzdir}");
var wasErased = fileSystem.directoryErase(pathToErase);
if (wasErased) {
    console.log("Path erased successfully - {0}".format(pathToErase));
}
```

### directoryExists

Checks if a directory exists.

**Version:**  5.1, 3.6 as *platform.directoryExists*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |

**Return Value:**

True if the path exists and it is a directory or drive, false otherwise.

**Example:**

```javascript theme={null}
var hasDDrive = fileSystem.directoryExists("d:\\");
if (hasDDrive) {
    console.log("System has a D drive!");
}
```

### directoryGetSize

Gets the size of the directory content allocated on the disk file system.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |
| callback | function | Callback function when complete. The second parameter contains boolean *successful* key and *result* numeric value. |

**Return Value:**

True if the path is valid directory and there is no an active directoryGetSize call, false otherwise.

**Example:**

```javascript theme={null}
fileSystem.directoryGetSize('C:\\temp\\', (sender, info) => { console.log("1: " + info); });
fileSystem.directoryGetSize('C:\\temp\\', (sender, info) => { console.log("2: " + info); });
// Output in the console:
// 2: {successful: false, result: 0} - Fails because the first call is still active
// 1: {successful: true, result: 20552329746}
```

### directoryIsEmpty

Checks to see if a directory is empty.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a directory |

**Return Value:**

True if the path is empty, false otherwise.

**Example:**

```json theme={null}
var isDirEmpty = fileSystem.directoryIsEmpty("c:\\temp\\");
console.log("Temp dir is empty!");
```

### fileCopy

Copies a file, overwriting if necessary.

**Version:**  5.1, 3.6 as *platform.fileCopy*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| sourceFilename | string | Path of the file to copy |
| targetFilename | string | Path of the file to write |
| failIfExists | boolean | If true, the function will fail if the target filename already exists. |

**Return Value:**

True if the file was successfully copied, false otherwise.

**Notes:**

* This function is a blocking call and long running operations can block the UI.
* Alternatively, use the fileCopy task.

### fileErase

Removes a file.

**Version:**  5.1, 3.6 as *platform.fileErase*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a file |

**Return Value:**

Returns 0 if the path was removed, OS error code otherwise.

### fileExists

Checks if a file exists.

**Version:**  5.1, 3.6 as *platform.fileExists*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to a file |

**Return Value:**

True if the path exists, false otherwise.

### fileGetSize

Gets the size of the file

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the file |

**Return Value:**

Size of the file in bytes.

**Example:**

```json theme={null}
var fileSizeBytes = fileSystem.fileGetSize("c:\\temp.log");
console.log("Size of temp log is {0}B".format(fileSizeBytes));
```

### fileRename

Renames a file from one location to another.

**Version:**  7.2.15

**Arguments:**

| Name | Type | Description |
| - | - | - |
| sourceFilename | string | Old location |
| targetFilename | string | New location |

**Return Value:**

True if the file was successfully renamed, false otherwise.

**Notes:**

* This function is a blocking call and long running operations can block the UI.

### getCreationTime

Gets the creation time for a file or directory.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to the file or directory |

**Return Value:**

Returns the unix timestamp of the file or directory's creation time if successful, otherwise it returns 0.

**Example:**

```json theme={null}
var modifiedTime = fileSystem.getCreationTime("c:\\myfile.txt");
```

### getFreeDiskSpace

Gets the number of free bytes on disk.

**Version:**  5.1, 3.6 as *platform.getFreeDiskSpace*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path on the drive to check for available space |

**Example:**

```json theme={null}
var bytesFree = fileSystem.getFreeDiskSpace(app.expandString("{systemDrive}"));
// bytesFree = 5368709120;
```

### getModifiedTime

Gets the modified time for a file or directory.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to the file or directory |

**Return Value:**

Returns the unix timestamp of the file or directory's modified time if successful, otherwise it returns 0.

**Example:**

```json theme={null}
var modifiedTime = fileSystem.getModifiedTime("c:\\myfile.txt");
```

### pathConvertFromUrl

Parses a path from a file:// url.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| url | string | URL to convert to path |

**Return Value:**

Returns the path, empty string otherwise.

### pathConvertToUrl

Parses a path to a file:// url.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to convert to URL |

**Return Value:**

Returns the url, empty string otherwise.

### pathFixSlash

Resolves dots, fixes slashes, and adds or removes a trailing slash.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to fix |
| trailingSlash | boolean | If *true* , return value will have a trailing slash, *false* otherwise. |

**Return Value:**

Returns fixed path.

**Example:**

```json theme={null}
var path = "temp/../xyz//log";
var fixedPath = fileSystem.pathFixSlash(path, true);
// Should be "xyz/log/" on linux/mac
// Should be "xyz\log\" on windows
```

### pathParseDirectory

Parses the directory from a path.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to parse |

**Return Value:**

Returns the directory parsed, empty string otherwise.

### pathParseExtension

Parses the extension from a path.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to parse |
| includeDot | bool | If *true* , return value includes dot, *false* otherwise. |

**Return Value:**

Returns the extension parsed, empty string otherwise.

### pathParseName

Parses the filename from a path.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to parse |

**Return Value:**

Returns the filename parsed, empty string otherwise.

### pathParseNameWithoutExtension

Parses the filename from a path without its extension.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to parse |

**Return Value:**

Returns the filename without extension parsed, empty string otherwise.

### pathResolve

Converts a tilde path into a full path and fixes slashes without modifying the trailing slash.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to resolve |

**Return Value:**

Returns resolved path.

**Example:**

```json theme={null}
var path = "~/temp/log.txt";
var resolvedPath = fileSystem.pathResolve(path);
// Should be "/users/username/temp/log.txt" on linux/mac
// Should be "c:\\users\\username\\temp\\log.txt" on windows
```

### setGroup

Ensures that a file is writable by all given user types.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to the file or directory |
| type | string | Type of user everyone users authenticated |

**Return Value:**

True on success and false on failure.

## HashFile

The HashFile class is used to asynchronous hash a binary file.

### getBytesLeft

Gets the number of bytes left to hash in the file.

**Version:**  7.1

### getDigest

Gets the hash digest when hashing is complete.

**Version:**  7.1

### getFileSize

Gets the total size of the file being hashed.

**Version:**  7.1

### getPath

Gets the path to the file to hash.

**Version:**  7.1

### setAlgorithm

Name of the hash algorithm.

**Version:**  7.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| algorithms | string | Name of hash algorithm. Supported algorithms: crc, md5, sha1, sha224, sha256, sha384, sha512 |

**Return Value:**

True if successful, false otherwise.

**Changes:**

* 7.0 - Removed MD2 and MD4 hash algorithms

### setPath

Sets the path to the file to hash.

**Version:**  7.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | File system path |

**Return Value:**

True if successful, false otherwise.

### start

Starts hashing.

**Version:**  7.1

## HttpRequest

The HttpRequest class is used by the JavaScript HttpRequestXhr class which functions as an XHR replacement.

### abort

Aborts the request.

**Version:**  3.6

### appendPostData

Appends data to post body.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| postData | string | Base-64 encoded post data |

**Return Value:**

True if successful, false otherwise.

### clearPostData

Clears the post body data.

**Version:**  3.6

### createHttpRequest

Creates an HTTP request object.

**Version:**  5.1

**Example:**

Recommend use of the HttpRequestXhr in JavaScript.  jQuery is setup to redirect requests to HttpRequestXhr.  Include 'httpRequestXhr' module in AngularJS.

### getAllowAuthentication

Gets whether or not the connection should support proxy, or HTTP authentication.

**Version:** 5.2

### getAllowProxy

Gets whether or not the connection should go through a proxy.

**Version:**  5.2

### getBody

Gets the response body buffer.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| offset | integer | Offset into the response buffer. |
| length | integer | Maximum length to retrieve. If the offset + length exceeds the buffer size, it will only return the remaining buffer. |

**Return Value:**

Base-64 encoded buffer of the response starting at offset with length. If the offset is invalid, the function will return null.

### getBodySize

Gets the response body size of the request.

**Version:**  3.6

### getCleanup

Gets whether or not it should delete the file when the object is released.

**Version:**  3.6

### getContentLength

Gets the content length of the response.

**Version:**  3.6

### getFileName

Gets the file name where the url is saved (empty to save to buffer).

**Version:**  3.6

### getFilePosition

Gets the current position in the file it is saving to.

**Version:**  3.6

### getHeader

Gets the request header buffer.

**Version:**  3.6

**Return Value:**

Gets the request headers.

### getHeaderValue

Gets the value of a request header.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Header name |

**Return Value:**

Returns the value of the header.

### getHttpCode

Gets the HTTP code that was returned in the response.

**Version:**  3.6

### getLimitBodySize

Gets the maximum body size for the request.

**Version:**  3.6

### getLimitRedirects

Get the maximum amount of allowed HTTP redirects. 0 means redirects are disallowed.

**Version:**  7.2

### getPartialFileName

Gets the partial file name where the url is saved

**Version:**  5.2

### getResponseHeader

Gets the response header buffer.

**Version:**  5.2

Gets the response headers.

### getResponseHeaderValue

Gets the value of a response header.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Header name |

**Return Value:**

Returns the value of the response header.

### getTimeout

Gets the seconds to wait for I/O before timeout.

**Version:**  3.6

### getType

Gets the type of HTTP request.

**Version:**  3.6

### getUrl

Gets the url for the request.

**Version:**  3.6

### getUseCache

Gets whether or not to use caching.

**Version:**  3.6

### hasResponseHeader

Checks if a value exists in the response header.

**Version:**  5.2, formerly as *headerExists*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Header name |

**Return Value:**

True if header exists, false otherwise.

### release

Release the instance.

**Version:**  3.6

### reset

Resets the request.

**Version:**  3.6

### setAllowAuthentication

Sets whether or not the connection should support proxy, or HTTP authentication.

**Version:**  5.2

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| allowAuthentication | boolean | Allow proxy, or HTTP authentication | true |

**Return Value:**

True if successful, false otherwise.

### setAllowProxy

Sets whether or not the connection should go through a proxy.

**Version:**  5.2

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| allowProxy | boolean | Allow connection to a proxy | true |

**Return Value:**

True if successful, false otherwise.

### setByteRange

Sets the byte range for the request.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| start | integer | Start of byte range |
| end | integer | End of byte range |

**Return Value:**

True if successful, false otherwise.

### setCleanup

Sets whether or not it should delete the file when the object is released.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| cleanup | boolean | Cleanup file when object is released |

**Return Value:**

True if successful, false otherwise.

### setFileName

Sets the file name where the url is saved (empty to save to buffer).

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| fileName | string | Path to a file to save request body |

**Return Value:**

True if successful, false otherwise.

### setHeaderValue

Sets the value of a request header.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Header name |
| value | string | Header value |

**Notes:**

* Header names and values are not evaluated for correctness.

**Return Value:**

True if successful, false otherwise.

### setLimitBodySize

Sets the maximum body size for the request.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| limitBodySize | integer | Maximum body size for request |

**Return Value:**

True if successful, false otherwise.

### setLimitRedirects

Sets the maximum amount of allowed HTTP redirects. 0 disallows redirects.

**Version:**  7.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| limitRedirects | integer | Amount of allowed redirects |

**Return Value:**

True if successful, false otherwise.

### setTimeout

Sets the seconds to wait for I/O before timeout.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| timeout | integer | Seconds to wait |

**Return Value:**

True if successful, false otherwise.

### setType

Sets the type of HTTP request.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | number | HTTP request type (see HttpRequestType) |

**Return Value:**

True if successful, false otherwise.

### setUrl

Sets the url for the request.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| url | string | Request URL |

**Return Value:**

True if successful, false otherwise.

### setUseCache

Sets whether or not to use caching.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| useCache | boolean | Use caching |

**Return Value:**

True if successful, false otherwise.

### start

Starts the request.

**Version:**  3.6

### waitForRequest

Blocking call to wait for request. Not recommended for use.  Only implemented for backwards compatibility for some old scripts.

**Version:**  5.1

## HttpRequestType

HTTP request type enumeration.

| Name | Description |
| - | - |
| GET | GET request |
| POST | POST request |
| PUT | PUT request |
| DELETE | DELETE request |
| HEAD | HEAD request |
| OPTIONS | OPTIONS request |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |

## NotificationCenter

Handles application notifications.

### addInstanceObserver

Watches for a notification center event on a specific object and fires a function when encountered.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| sender | object w/ instanceId | Event sender |
| func | function | Observer callback |

**Return Value:**

Returns an observer object which can be released/deleted when the observer is no longer needed.

**Example:**

```json theme={null}
var observer = notificationCenter.addInstanceObserver("MyClass", "MyEvent", myclass, function(sender, info) {
    console.log(info);
    observer.release();
});
notificationCenter.fire("MyClass", "MyEvent", myclass, { "mydata": "myvalue" });
```

### addObserver

Watches for a notification center event and fires a function when encountered.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| func | function | Observer callback |

**Return Value:**

Returns an observer object which can be released/deleted when the observer is no longer needed.

**Example:**

```json theme={null}
var observer = notificationCenter.addObserver("MyClass", "MyEvent", function(sender, info) {
    console.log("Event: MyClass.MyEvent - {0}".format(interop.getInstanceId(sender)));
    console.log(info);
    observer.release();
});
notificationCenter.fire("MyClass", "MyEvent", myclass, { "mydata": "myvalue" });
```

### fire

Fires a notification center event instantly. The notification event will be fired both in the JavaScript layer and the Interop layer.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| sender | object w/ instanceId | Event sender |
| info | object | Event info |

**Example:**

```json theme={null}
function MyClass() {
    this.instanceId = app.expandString("{guid}");
};
myclass = new MyClass();
notificationCenter.fire("MyClass", "MyEvent", myclass, { "mydata": "myvalue" });
```

### fireAfterDelay

Fires a notification center event after a certain amount of time has elapsed. The notification event will be fired both in the JavaScript layer and the Interop layer.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| sender | object w/ instanceId | Event sender |
| delay | integer | Delay in milliseconds |
| info | object | Event info |

**Example:**

```json theme={null}
function MyClass() {
    this.instanceId = app.expandString("{guid}");
};
myclass = new MyClass();
notificationCenter.fireAfterDelay("MyClass", "MyEvent", myclass, 1000, { "mydata": "myvalue" });
```

### removeInstanceObserver

Removes an observer from a specific object given its callback.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| sender | object w/ instanceId | Event sender |
| func | function | Observer callback |

**Example:**

```json theme={null}
var myEventCallback = function(sender, info) {
    console.log("Event: MyClass.MyEvent - {0}".format(interop.getInstanceId(sender)));
    console.log(info);
};
notificationCenter.addInstanceObserver("MyClass", "MyEvent", myclass, myEventCallback);
notificationCenter.fire("MyClass", "MyEvent", myclass, { "mydata": "myvalue" });
notificationCenter.removeInstanceObserver("MyClass", "MyEvent", myclass, myEventCallback);
```

### removeObserver

Removes an observer given its callback.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Event type |
| notification | string | Event name |
| func | function | Observer callback |

**Example:**

```json theme={null}
var myEventCallback = function(sender, info) {
    console.log("Event: MyClass.MyEvent - {0}".format(interop.getInstanceId(sender)));
    console.log(info);
};
notificationCenter.addObserver("MyClass", "MyEvent", myEventCallback);
notificationCenter.fire("MyClass", "MyEvent", myclass, { "mydata": "myvalue" });
notificationCenter.removeObserver("MyClass", "MyEvent", myEventCallback);
```

## Pipe

Represents a system pipe object.

### createPipe

Creates a new pipe instance.

**Version:**  3.6

**Example:**

```json theme={null}
var pipe = createPipe();

pipe.setName("globalPipeName");
pipe.setOpenExisting(false);

var readObserver = notificationCenter.addInstanceObserver("Pipe", "Read", pipe, (sender, info) => {
    var data = JSON.parse(atob(info.buffer));
	console.log("Pipe read - {0}".format(data));
    if (data.hasOwnProperty("hello") && data.hello == "world") {
         readObserver.release();
         pipe.release();
    }
});

pipe.start();
```

### getBufferSize

Gets buffer size of the pipe for reading and writing.

**Version:**  3.6

### getName

Gets the name of the pipe. Optional in 7.0

**Version:**  3.6

### getOpenExisting

Gets whether or not it will open an existing pipe.

**Version:**  3.6

### release

Releases the instance.

**Version:**  3.6

### setBufferSize

Sets the buffer size of the pipe for reading and writing.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| bufferSize | integer | Size of the buffer |

### setName

Sets the optional name of the pipe; if empty, the unnamed/anonymous pipe will open

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Name of the pipe |

**Return Value:**

True if the name was set, false otherwise.

### setOpenExisting

Sets whether or not it will open an existing pipe.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| openExisting | boolean | If true, it will open an existing pipe, false otherwise. Ignored, if the name is empty. |

**Return Value:**

True if the value was set, false otherwise.

### start

Opens a pipe for reading and writing.

**Version:**  3.6

**Return Value:**

True if successfully started reading, false otherwise. Pipe reads will be streamed on the Pipe.Read notification.

### write

Writes to the pipe

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| buffer | string | Base64 string representing the data to write to the pipe |

**Return Value:**

Returns the number of bytes written to the byte.

**Example:**

```json theme={null}
var pipe = createPipe();

pipe.setName("globalPipeName");
pipe.setOpenExisting(true);
if (pipe.start()) {
    var data = {"hello": "world"};
    pipe.write(btoa(JSON.stringify(data)));
}
pipe.release();
```

## Platform

System platform functions.

### access

Determines if the current process has desired access to the directory.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to the directory |
| permissions | int | Desires process access flags platformAccessPermissions.READ platformAccessPermissions.WRITE |
| recurse | boolean | If true, and the path does not exist then navigate upward until one is found that does exist |

**Return Value:**

If the current process has the specified permissions it returns true, false otherwise.

**Example:**

```json theme={null}
var installDir = app.expandString("{programFiles}");
var canWrite = platform.access(installDir, platformAccessPermissions.WRITE, false);
```

### authenticateX509

Validates a certificate .DER file on disk.

**Version:**  5.1, 3.6 as *platform.authenticateCertificate*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the certificate to validate |

**Return Value:**

True if the certificate is valid, false otherwise.

**Example:**

```json theme={null}
var isValidCert = platform.authenticateX509(app.expandString("{userDesktop}cert.der"));
```

### createShortcut

Creates a virtual shortcut on the system.

**Version:**  3.6

**Supported OS:**

* Windows
* Linux

**Arguments:**

| Name | Type | Description |
| - | - | - |
| executable | string | Path to the application |
| parameter | string | Arguments to the application |
| iconId | integer | ID of the icon to use for the shortcut (Windows only) |
| location | string | Directory to create the shortcut in |
| description | string | Name of the shortcut |
| iconLocation | string | Location of an external icon (optional). Windows: If the location specifies a DLL or executable, then *iconId* refers to the resource ID or index. |
| flags | integer | Shortcut creation flags (optional) 0x01 = Run as admin (Windows only) |

**Return Value:**

True if the shortcut was created, false otherwise.

**Example:**

```json theme={null}
var programPath = app.expandString("{pathJoin:{programFiles},myco,myapp.exe}");
var shortcutDir = app.expandString("{userDesktop}");
platform.createShortcut(programPath, "--debug", 0, shortcutDir, "My Application", "", 0);
```

### findProcess

Finds the specified process open on the system.

**Version:**  5.1, 3.6 as *platform.isProcessRunning*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the process to locate |

**Return Value:**

Returns the ID of the process if found. If the process is not found, it returns -1.

**Example:**

```json theme={null}
var processId = platform.findProcess(app.expandString("{userDesktop}procmon.exe"));
```

### findWindow

Finds the specified window open on the system.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| caption1 | string | Caption to search for (supports wildcards) |
| className1 | string | Class name to search for (supports wildcards) |
| searchOnlyVisible | boolean | Whether or not to search only visible windows |

**Notes:**

1. If both caption and className are specified, it will try to match either field. To match only a specific field, specify an empty string for the other.

**Return Value:**

True if the specified window was found, false otherwise.

**Example:**

Matches all windows whose caption begins with "Internet Explorer" and are visible.

```json theme={null}
var found = platform.findWindow("Internet Explorer*", "", true);
```

Matches all windows whose caption begins with "Internet Explorer" OR have a class name of "IE\_Window" and are visible.

```json theme={null}
var found = platform.findWindow("Internet Explorer*", "IE_Window", true);
```

### getCredential

Gets a credential from the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.getCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| target | string | Name of the item in the store |

**Return Value:**

Returns a JSON object if successful, false otherwise:

| Name | Type | Description |
| - | - | - |
| username | string | Credential username |
| password | string | Credential password |

### getCurrentProcessId

Gets the ID for the current process.

**Version:**  7.2.54

### getDataStore

Gets the base-64 encoded unauthenticated datastore for the current application.

**Version:**  5.2

**Example:**

```json theme={null}
var base64DataStore = platform.getDataStore();
var dataStore = atob(base64DataStore);
```

### getFileDataStore

Gets the base-64 encoded datastore for a particular file.

**Version:**  5.2

**Example:**

```json theme={null}
var base64DataStore = platform.getFileDataStore("c:\\users\\username\\desktop\\host-signed.exe");
var dataStore = atob(base64DataStore);
```

### getModuleDistribution

Gets the DirectGVR deployment name for the current process.  See documentation for `{moduleDistribution}` for possible values.

**Version:**  7.2.60

### getName

Gets the name of the platform.

**Version:**  5.2

**Example:**

```json theme={null}
var name = platform.getName();
// name = "Windows NT"
```

**Example:**

Returns the name of the platform.  The results are the same as using the \{systemName} macro.

### getParentProcessId

Gets the parent process id for a process given its process id.

**Version:**  8.0.5

**Arguments:**

| Name | Type | Description |
| - | - | - |
| process\_id | integer | Process id |

**Return Value:**

Returns the id of process' parent if successful.

**Example:**

```json theme={null}
var path = platform.getParentProcessId(41704);
```

### getProcessPath

Gets the path for a process given its process id.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Process id |

**Return Value:**

Returns the path to the process if successful, otherwise an empty string.

**Example:**

```json theme={null}
var path = platform.getProcessPath(41704);
```

### getShortName

Gets the short name of the platform.

**Version:**  5.2

**Example:**

```json theme={null}
var name = platform.getShortName();
// name = "win", "mac", "linux"
```

**Example:**

Returns the short name of the platform. The results are the same as using the \{systemShortName} macro.

### getSystemTheme

Gets the name of the current system theme.

**Version:**  6.1

**Example:**

```json theme={null}
var theme = platform.getSystemTheme();
// theme = "light", "dark"
```

### getUserCountry

Gets the current user's country set on the machine in ISO 3166 format.

**Version:**  5.1

**Example:**

```json theme={null}
var countryCode = platform.getUserCountry();
// countryCode = "US";
```

### getUserLanguage

Gets the current user's language set on the machine in ISO 639 format.

**Version:**  5.1

**Example:**

```json theme={null}
var langCode = platform.getUserLanguage();
// langCode = "en";
```

### getUserName

Gets the current user's name.

**Version:**  5.2

**Example:**

```json theme={null}
var userName = platform.getUserName();
// userName = "username"
```

**Example:**

Returns the current users name used by the system.  The results are the same as using the \{userName} macro.

### getWebCredential

Gets a web credential from the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.getWebCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| accessType | int | Web credential type |
| host | string | Hostname |
| realm | string | Authentication realm |

**Return Value:**

Returns a JSON object if successful, false otherwise:

| Name | Type | Description |
| - | - | - |
| username | string | Credential username |
| password | string | Credential password |

### preventSystemSleep

Prevents or allows the system to sleep.

**Version:**  7.2.15

**Arguments:**

| Name | Type | Description |
| - | - | - |
| prevent | boolean | If *true* , prevents the system from sleeping, otherwise it allows the system to go to sleep. |

**Return Value:**

True if successful, false otherwise.

**Example:**

```javascript theme={null}
// prevent the system from sleeping
platform.preventSystemSleep(true);
// allow the system to sleep
platform.preventSystemSleep(false);
```

### reboot

Reboots the system.

**Version:**  3.6

**Example:**

```json theme={null}
platform.reboot();
```

### removeCredential

Removes a credential from the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.removeCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| target | string | Name of the item in the store |

**Return Value:**

True if successful, false otherwise.

### removeShortcut

Removes a shortcut from the system.

**Version:**  3.6

**Supported OS:**

* Windows
* Linux

**Arguments:**

| Name | Type | Description |
| - | - | - |
| location | string | Directory the shortcut was created in |
| description | string | Name of the shortcut |

**Return Value:**

True if the shortcut was removed, false otherwise.

**Example:**

```json theme={null}
var shortcutDir = app.expandString("{userDesktop}");
platform.removeShortcut(shortcutDir, "My Application");
```

### removeWebCredential

Removes a web credential from the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.removeWebCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| accessType | int | Access type |
| host | string | Hostname |
| realm | string | Authentication realm |

**Return Value:**

True if successful, false otherwise.

### setEnvironmentVariable

Sets a process environment variable.

**Version:**  6.1.0.74

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Name of the variable |
| value | string | Value of the variable |

**Return Value:**

True if successful, false otherwise.

### setCredential

Sets a credential in the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.setCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| target | string | Name of the item in the store |
| username | string | Credential username |
| password | string | Credential password |

**Return Value:**

True if successful, false otherwise.

### setWebCredential

Sets a web credential in the system credential store.

**Version:**  5.2, 5.1 as*workflowApp.setWebCredential*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| accessType | int | Web credential type |
| host | string | Hostname |
| realm | string | Authentication realm |
| username | string | Credential username |
| password | string | Credential password |

**Return Value:**

True if successful, false otherwise.

### shellOpen

Runs a system shell command.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path of the command to run. |
| arguments | string | Optional arguments to pass to the process. (Not supported on Ubuntu) |

**Result:**

Run the command specified by path. If you specify a file as the path, the system will open the file with its associated application. If you specify a folder as the path, the system will open up the folder in its file explorer.

**Changes in 7.1:**

* Added new arguments parameter

**Example:**

```json theme={null}
platform.shellOpen(app.expandString("{userDesktop}"));
// Opens the desktop folder in the operating system's file explorer
```

### terminateProcess

Terminates a process given its ID by sending close messages to the main windows of the process.

**Version:**  7.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | int | Process ID |

**Return Value:**

True if successful, false otherwise.

### terminateProcessForcefully

Terminates a process given its ID by killing it.

**Version:**  7.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | int | Process ID |
| exitCode | int | Exit code (Windows only) |

**Return Value:**

True if successful, false otherwise.

### timeToRFC1123

Converts a unix timestamp in to its RFC1123 representation.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| date | integer | The unix timestamp |

**Return Value:**

RFC1123 string representation of the unix timestamp provided.

**Example:**

```json theme={null}
var timestring = platform.timeToRFC1123(1528221164);
// timestring = "Tue, 05 Jun 2018 17:52:44 GMT";
```

### translateError

Translates basic OS error to a simple string

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| error | integer | The basic OS error code |

**Return Value:**

The return value can be a string of one of the following values:

* None
* Missing
* AccessDenied
* AccessInvalid
* NotEnoughSpace
* Locked
* NotSupported
* Unknown

**Example:**

```json theme={null}
var errorId = platform.translateError(5);
// errorId = "AccessDenied";
```

### unsetEnvironmentVariable

Unsets a process environment variable.

**Version:** 6.2.2, 7.1.13

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Name of the variable |

**Return Value:**

True if successful, false otherwise.

## PlatformAccessPermissions

Access permission flags.

| Name | Description |
| - | - |
| READ | Read permission |
| WRITE | Write permission |

### nameFromId

Returns a string representing the specified flag values.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Access permission |

## PlatformWebCredentialType

Web credential type constants.

**Version:**  5.2

| Name | Description |
| - | - |
| SERVER | Server authentication |
| PROXY | Proxy authentication |

### nameFromId

Returns a string representing the specified constant values.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Web credential type |

## Process

Execute a process.

### createProcess

Creates a new process instance.

**Version:**  3.6

### getId

Gets the ID of the process after it has been launched.

**Version:**  3.6

### getApplicationName

Gets the name of the application.

**Version:**  3.6

### getArguments

Gets the arguments that will be used when launching the process.

**Version:**  3.6

### getAuthenticateTarget

Gets the authentication target for verification. Uses application if blank.

**Version:**  3.6

### getElevationRights

Gets the elevation rights value that will be used for the process launch.

**Version:**  3.6

### getRunningTime

Gets the time the application has been running in seconds.

**Version:**  3.6

### getSHA1

Gets the SHA1 of the application executable.

**Version:**  3.6

### getSHA1Target

Gets the optional target used for SHA1 calculation.

**Version:**  3.6

### getShortApplicationName

Gets the filename of the application.

**Version:**  3.6

### getShowWindow

Gets whether or not the process should be visible when launching.

**Version:**  3.6

**OS Support:**

* Windows

### getStderr

Gets the pipe for the process standard error stream.

**Version:**  6.1

### getStdin

Gets the pipe for the process standard input stream.

**Version:**  6.1

### getStdout

Gets the pipe for the process standard output stream.

**Version:**  6.1

### getWorkingDirectory

Gets the working directory used when launching the process.

**Version:**  3.6

### launch

Launches the process.

**Version:**  3.6

**Example:**

```json theme={null}
var proc = createProcess();

proc.setApplicationName(app.expandString("{userDesktop}myapp.exe"));
proc.setArguments("--debug");
proc.setShowWindow(true);

var completeObserver = notificationCenter.addInstanceObserver("Process", "Complete", proc, (sender, info) => {
    console.log("Process Launch Results - Successful {0} ExitCode {1}".format(info.successful, info.exitCode));
    completeObserver.release();
    proc.release();
});

proc.launch();
```

### release

Releases the instance.

**Version:**  3.6

### setApplicationName

Sets the application name to launch.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| applicationName | string | Path to the application |

**Return Value:**

True if successful, false otherwise.

### setArguments

Sets the arguments that will be used when launching the process.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| args | string | Arguments |

**Return Value:**

True if successful, false otherwise.

### setAuthenticateCertStore

Sets the optional certificate store for verification. Uses app store if blank.

**Version:**  7.2.27

**Arguments:**

| Name | Type | Description |
| - | - | - |
| certStoreName | string | Name of the certificate store in the app config |

**Return Value:**

True if successful, false otherwise.

### setAuthenticateTarget

Sets the optional certificate authentication target for verification. Uses applicationName if blank.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| authenticateTarget | string | Path to authenticate |

**Return Value:**

True if successful, false otherwise.

### setDigest

Sets the expected hash digest to verify against. If set, it will check the hash of the application prior to launching. Blank to skip check.

**Version:**  7.2.27 (previously *setSHA1*  before 7.2.27, initially introduced in 3.6)

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | string | Hash type md5, sha1, sha256, sha512 |
| value | string | Expected hash value |

**Return Value:**

True if successful, false otherwise.

### setDigestTarget

Sets an optional target used for hash verification. Uses application path if blank.

**Version:**  7.2.27 (previously *setSHA1Target*  before 7.2.27, initially introduced in 3.6)

**Arguments:**

| Name | Type | Description |
| - | - | - |
| digestTarget | string | Path to the executable to verify |

**Return Value:**

True if successful, false otherwise.

### setElevationRights

Sets the elevation rights that will be used when launching the process.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| elevationRights | integer | Process elevation rights processElevationRights.USER processElevationRights.ELEVATED processElevationRights.INVOKER |

**Return Value:**

True if successful, false otherwise.

### setShowWindow

Sets whether or not the process should be visible when launching.

**Version:**  3.6

**OS Support:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| showWindow | boolean | If true, show the window, otherwise hide the window. |

**Return Value:**

True if successful, false otherwise.

### setStderr

Sets the pipe for the process standard error stream.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| stderr | string | pipe instance |

**Return Value:**

True if successful, false otherwise.

### setStdin

Sets the pipe for the process standard input stream.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| stdin | string | pipe instance |

**Return Value:**

True if successful, false otherwise.

### setStdout

Sets the pipe for the process standard output stream.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| stdout | string | pipe instance |

**Return Value:**

True if successful, false otherwise.

**Example:**

```javascript theme={null}
var pipe = createPipe();
 
var pipeObserver = notificationCenter.addInstanceObserver("Pipe", "Read", pipe, function(sender, info) {
    var data = atob(info.buffer);
    console.log(data);
});
 
var proc = createProcess();
 
proc.setApplicationName("C:\\Windows\\System32\\HOSTNAME.EXE");
proc.setArguments("/?");
proc.setShowWindow(false);
process.setStdout(pipe);
 
var completeObserver = notificationCenter.addInstanceObserver("Process", "Complete", proc, function(sender, info) {
    console.log("Process Launch Results - Successful {0} ExitCode {1}".format(info.successful, info.exitCode));
    completeObserver.release();
    proc.release();
    pipeObserver.release();
    pipe.release();
});
 
if (!proc.launch()) {
    console.log("Unable to launch process";);
    completeObserver.release();
    proc.release();
    pipeObserver.release();
    pipe.release();
}
```

### setWorkingDirectory

Sets the working directory used when launching the process.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| workingDirectory | string | Path to the directory |

**Return Value:**

True if successful, false otherwise.

## ProcessElevationRights

Elevation rights enumeration.

| Name | Description |
| - | - |
| USER | User rights |
| ELEVATED | Elevated rights |
| INVOKER | Current rights |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |

## Registry

System registry functions.

**OS Support:**

* Windows

**Registry view enumeration values:**

* default
* 32
* 64

**Registry hive enumeration values:**

* user
* performance
* machine
* root
* config
* desktopuser

### deleteKey

Deletes a key in the registry.

**Version:**  5.1, 3.6 as *platform.registryDeleteKey*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| type | string | Type of the hive |
| key | string | Path of the key |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
if (registry.deleteKey("default", "user", "SOFTWARE\\MyCo")) {
   console.log("Registry key deleted!");
}
```

### deleteValue

Deletes a value in the registry.

**Version:**  5.1, 3.6 as *platform.registryDeleteValue*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| type | string | Type of the hive |
| key | string | Path of the key |
| name | string | Name of the value |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
if (registry.deleteValue("default", "user", "SOFTWARE\\MyCo", "Version")) {
   console.log("Registry key value deleted!");
}
```

### getData

Gets a base-64 encoded string of a binary registry value.

**Version:**  5.2

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. | |
| type | string | Type of the hive | |
| key | string | Path of the key | |
| name | string | Name of the value | |
| defaultValue | integer | Default value if not found | "" |

**Example:**

```json theme={null}
var token = registry.getData("default", "user", "SOFTWARE\\MyCo", "Token", "");
// token = "dG9rZW52YWx1ZQ==";
```

### getInt32

Gets a 32-bit integer value from the registry.

**Version:**  5.1, 3.6 as *platform.getRegistryInt32*

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. | |
| type | string | Type of the hive | |
| key | string | Path of the key | |
| name | string | Name of the value | |
| defaultValue | integer | Default value if not found | 0 |

**Example:**

```json theme={null}
var isInstalled = registry.getInt32("default", "user", "SOFTWARE\\MyCo", "IsInstalled");
// isInstalled = 1;
```

### getInt64

Gets a 64-bit integer value from the registry.

**Version:**  5.1

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. | |
| type | string | Type of the hive | |
| key | string | Path of the key | |
| name | string | Name of the value | |
| defaultValue | integer | Default value if not found | 0 |

**Example:**

```json theme={null}
var bytesRequired = registry.getInt64("default", "user", "SOFTWARE\\MyCo", "DiskSpaceRequired");
// bytesRequired = 1000000000;
```

### getString

Gets a string value from the registry.

**Version:**  5.1, 3.6 as *platform.getRegistryString*

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. | |
| type | string | Type of the hive | |
| key | string | Path of the key | |
| name | string | Name of the value | |
| defaultValue | string | Default value if not found | "" |

**Example:**

```json theme={null}
var version = registry.getString("default", "user", "SOFTWARE\\MyCo", "Version");
// version = "1.0.0.0";
```

### keyExists

Checks to see if a registry key path exists.

**Version:**  5.1, 3.6 as *platform.registryKeyPathExists*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| type | string | Type of the hive |
| key | string | Path of the key |

**Return Value:**

True if the key exists, false otherwise.

**Example:**

```json theme={null}
if (registry.keyExists("default", "user", "SOFTWARE\\MyCo")) {
   console.log("Registry key exists!");
}
```

### setData

Sets a binary value in the registry from a base-64 encoded string and creates the registry key if it does not already exist.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| security | string | Security group default everyone users administrators |
| type | string | Type of the hive |
| key | string | Path of the key |
| name | string | Name of the value |
| value | string | Base-64 string of the binary data |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
registry.setData("default", "default", "user", "SOFTWARE\\MyCo", "Token", bota("tokenvalue"));
```

### setInt32

Sets a 32-bit integer value in the registry and creates the registry key if it does not already exist.

**Version:**  5.1, 3.6 as *platform.setRegistryInt32*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| security | string | Security group default everyone users administrators |
| type | string | Type of the hive |
| key | string | Path of the key |
| name | string | Name of the value |
| value | integer | Integer value |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
registry.setInt32("default", "default", "user", "SOFTWARE\\MyCo", "IsInstalled", 1);
```

### setInt64

Sets a 64-bit integer value in the registry and creates the registry key if it does not already exist.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| security | string | Security group default everyone users administrators |
| type | string | Type of the hive |
| key | string | Path of the key |
| name | string | Name of the value |
| value | integer | Integer value |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
registry.setInt64("default", "default", "user", "SOFTWARE\\MyCo", "DiskSpaceRequired", 1000000000);
```

### setString

Sets a string value in the registry and creates the registry key if it does not already exist.

**Version:**  5.1, 3.6 as *platform.setRegistryString*

**Arguments:**

| Name | Type | Description |
| - | - | - |
| view | string | View of the hive. If the view specified does not exist, the *default* view will be used. |
| security | strng | Security group default everyone users administrators |
| type | string | Type of the hive |
| key | string | Path of the key |
| name | string | Name of the value |
| value | string | Value string |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
registry.setString("default", "default", "user", "SOFTWARE\\MyCo", "Version", "1.0.0.0");
```

## SkinFileExtract

### getFilename

Gets the filename to extract from the skin.

**Version:**  3.6

### setFilename

**Version:** 3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| filename | string | Filename in the skin |

**Return Value:**

True if successful, false otherwise.

### getOutputFilename

Gets the filename on disk to extract to.

**Version:**  3.6

### setOutputFilename

Sets the filename on disk to extract to

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| filename | string | Filename in the skin |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
// Extract skin file read.json to disk
var extractor = createSkinFileExtract();
extractor.setFilename("read.json");
extractor.setOutputFilename("c:\\test\\read.json");
var completeObserver = notificationCenter.addInstanceObserver("SkinFileExtract", "Complete", extractor, function(sender, info) {
    // Do what we want, output file should be written now
    completeObserver.release();
    extractor.release();
});

extractor.start();
```

### getBuffer

Gets the buffer.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| offset | integer | Offset into the buffer |
| length | integer | Maximum length of the buffer to get. If the offset + length exceeds the buffer size, it will only return the remaining buffer. |

**Return Value:**

Returns length bytes of the buffer beginning at offset. Output is base64 encoded. If offset is invalid return value is null.

### getBufferSize

Gets the size of the buffer.

**Version:**  3.6

### start

Starts extraction.

**Version:**  3.6

### createSkinFileExtract

Creates a new instance of SkinFileExtract.

**Version:**  3.6

**Example:**

```json theme={null}
var extractor = createSkinFileExtract();
extractor.setFilename("read.json");
var completeObserver = notificationCenter.addInstanceObserver("SkinFileExtract", "Complete", extractor, function(sender, info) {
    var offset = 0, chunk, chunkLength = 2048, text = null, textLength = 0;
    completeObserver.release();
    if (info.successful) {
        text = "";
        textLength = extractor.getBufferSize();
        do {
            chunk = atob(extractor.getBuffer(offset, chunkLength));
            text += chunk;
            offset += chunkLength;
        }
        while (chunk.length > 0 && text.length < textLength);
        chunk = null;
        console.log("File extracted!");
    }
    extractor.release();
});

extractor.start();
```

### release

Releases the instance.

**Version:**  3.6

## SkinWindow

Host window functions.

### beginMove

Informs the native window of any movement so that the native/browser window can be synchronized.

**Version:**  3.6

### beginSize

Informs the native window of any movement so that the native/browser window can be synchronized.

**Version:**  3.6

### browseForFile

Show the file selection dialog center above the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| text | string | Caption text |
| fileTypeDesc | string | Description of the file type to allow |
| fileTypeExt | string | File extension to allow selection |
| startPath | string | Folder to start selection in |
| startFile | string | File to start selection |
| callback | function | Function to call to get the result. First parameter contains boolean *successful* key and string *path* key. |

**Return Value:**

Notification center event with value that was selected by the user.

**Changes in 6.1:**

* Added new callback parameter

**Example:**

```json theme={null}
var suggestedPath = app.expandString("{userDesktop}");
skinWindow.browseForFile("Select your certificate", "Certificates (.pfx)", "*.pfx", suggestedPath, "", (sender, info) => {
    if (info.successful) {
        console.log("File selected - {0}".format(info.path));
    }
});
```

### browseForFolder

Show the folder selection dialog center above the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| text | string | Caption text |
| startPath | string | Directory to start the selection in |
| callback | function | Function to call to get the result. First parameter contains boolean *successful* key and string *path* key. |

**Return Value:**

Notification center event with value that was selected by the user.

**Changes in 6.1:**

* Added new callback parameter

**Example:**

```json theme={null}
skinWindow.browseForFolder("Select your folder", app.expandString("{userDesktop}"), (sender, info) => {
    if (info.successful) {
        console.log("Path selected - {0}".format(info.path));
    }
});
```

### center

Centers the window in the current view port.

**Version:**  3.6

### close

Closes the window.

**Version:**  3.6

### getCanClose

Gets whether or not the operating system can close the window.

**Version:**  5.1

### getCanHide

Gets whether or not the operating system can hide the window.

**Version:**  5.1

**Supported OS:**

* Windows

### getCanMaximize

Gets whether or not the operating system can maximize the window.

**Version:**  5.2

### getCanMinimize

Gets whether or not the operating system can minimize the window.

**Version:**  5.1

### getCanMove

Gets whether or not the operating system can move the window.

**Version:**  5.1

### getCanRestore

Gets whether or not the operating system can restore the window.

**Version:**  5.1

**Supported OS:**

* Windows

### getCanShow

Gets whether or not the operating system can show the window.

**Version:**  5.1

**Supported OS:**

* Windows
* Macintosh

### getConfig

Gets a configuration setting from the window config.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | Config key |
| defaultValue | string | Default value if config key is not found |

**Return Value:**

Returns the configuration value or the default value if it is not found.

**Example:**

```json theme={null}
var minWidth = skinWindow.getConfig("minWidth", 900);
```

### getDroppedFilePaths

Gets list of files or folders that were dropped. Should be accessed from with-in the JS DOM drop event handler.

**Version:**  8.0.15

**Return Value:**

Returns an array of files or folders, or empty if no files dropped.

**Example:**

```json theme={null}
document.addEventListener("drop", (e) => {
    e.preventDefault();
    var droppedFiles = skinWindow.getDroppedFilePath();
    console.log({droppedFiles});
});
```

### getHeight

Gets the height of the window.

**Version:**  3.6

### getMinHeight

Gets the minimum height of the window.

**Version:**  3.6

### getMinimizeToNotificationArea

Gets whether or not the window will minimize to the notification area.

**Version:**  3.6

**OS Support:**

* Windows

### getMinWidth

Gets the minimum width of the window.

**Version:**  3.6

### getPopupFrame

Gets the type of popup window frame.

**Version:**  6.1

### getScreenHeight

Gets the height of the screen the window is on.

**Version:**  5.2

### getScreenInfo

Gets information about the screen the window is on.

**Version:**  7.2.62

**Return Value:**

Returns an object with screen information.

| Name | Type | Description |
| - | - | - |
| primary | boolean | Is primary monitor |
| scaleFactor | number | Text/backing scaling factor |
| dpi | object | DPI (x, y) |
| bounds | object | Rectangle bounds of the screen (x, y, width, height) |
| size | object | Size of the screen (width, height) |
| workArea | object | Rectangle of the work area of the screen minus the taskbar. (x, y, width, height) |
| workAreaSize | object | Size of the work area (width, height) |

### getScreenWidth

Gets the width of the screen the window is on.

**Version:**  5.2

### getTitle

Gets the title for the window.

**Version:**  3.6

### getUseNotificationArea

Gets whether or not the window shows an icon the notification area.

**Version:**  3.6

**OS Support:**

* Windows

### getWidth

Gets the width of the window.

**Version:**  3.6

### getWindowFrame

Gets the type of window frame used.

**Version:**  3.6

### getX

Gets the horizontal position of the window on the screen.

**Version:**  3.6

### getY

Gets the vertical position of the window on the screen.

**Version:**  3.6

### hide

Hides the window.

**Version:**  3.6

### isActivated

Checks if the window is currently activated/focused.

**Version:**  7.1

### isMaximized

Checks if the window is currently maximized.

**Version:**  3.6

### isMinimized

Checks if the window is currently minimized.

**Version:**  5.2

### isVisible

Checks if the window is currently visible.

**Version:**  3.6

### loaded

Notify the client that the window has loaded. Prevents the client from showing a timeout message waiting to load. Calling *skinWindow\.show()*  is sufficient to prevent the timeout message from showing. In applications that automatically minimize to tray and do not show immediately, or applications that don't show a window, it is necessary to call this function.

**Version:**  5.1

**Example:**

```json theme={null}
skinWindow.loaded();
```

### maximize

Maximizes the window.

**Version:**  5.2

### messageBox

Shows and asks the user to response to a message box.

**Version:**  5.1, 3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| text | string | Message box text |
| caption | string | Message box caption |
| type | integer | Message box type |
| callback | function | Function to call to get the result. First parameter contains boolean *successful* key and skinWindowMessageBox enum *result* key. |

**Return Value:**

Returns the message box constant that the user selected.

**Changes in 6.1:**

* Added new callback parameter

**Example:**

```json theme={null}
skinWindow.messageBox("Question #1", "Yes or no?", skinWindowMessageBox.YES | skinWindowMessageBox.NO, function(sender, info) {
    if (info.successful) {
        if (info.result == skinWindowMessageBox.YES) {
            console.log("User selected YES!");
        } else if (info.result == skinWindowMessageBox.NO) {
            console.log("User selected NO!");
        }
    }
});
```

### minimize

Minimizes the window.

**Version:**  3.6

### notify

Sends a notification message to the OS.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| type | integer | Type of notification (see SkinWindowNotify) |
| caption | string | Caption for the notification |
| message | string | Text for the notification |

**Example:**

```json theme={null}
skinWindow.notify(skinWindowNotify.INFO, "App", "Your app is out-of-date!");
```

### restore

Restores the window after a minimize or maximize.

**Version:**  3.6

### saveImage

Saves a PNG or BMP type image of the browser window to disk.

**Version:**  3.6

**Browser Support:**

* CEF

**Arguments:**

| Name | Type | Description |
| - | - | - |
| path | string | Path to save the image on disk |

**Changes in 6.1:**

* Requires cef.offscreenRender enabled in app config

**Return Value:**

True if successful, false otherwise.

### setBigIcon

Sets the big icon for the window. When disabled it shows the application icon.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | X coordinate of the icon in the sprite map. |
| y | integer | Y coordinate of the icon in the sprite map. |
| width | integer | Width of the icon in the sprite map. (0 to disable) |
| height | integer | Height of the icon in the sprite map. (0 to disable) |

**Return Value:**

True if successful, false otherwise.

### setCanClose

Sets whether or not the operating system can close the window. Should be used during shutdown to indicate whether or not the window is ready to close. All interop instances should be released before setCanClose has been set true to ensure that instances are not leaked.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canClose | boolean | Window can close |

**Return Value:**

True if successful, false otherwise.

### setCanHide

Sets whether or not the operating system can hide the window.

**Version:**  5.1

**Supported OS:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canHide | boolean | Window can hide |

**Return Value:**

True if successful, false otherwise.

### setCanMaximize

Sets whether or not the operating system can maximize the window.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canMaximize | boolean | Window can maximize |

**Return Value:**

True if successful, false otherwise.

### setCanMinimize

Sets whether or not the operating system can minimize the window.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canMinimize | boolean | Window can minimize |

**Return Value:**

True if successful, false otherwise.

### setCanMove

Sets whether or not the operating system can move the window.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canMove | boolean | Window can move |

**Return Value:**

True if successful, false otherwise.

### setCanRestore

Sets whether or not the operating system can restore the window.

**Version:**  5.1

**Supported OS:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canRestore | boolean | Window can restore |

**Return Value:**

True if successful, false otherwise.

### setCanShow

Sets whether or not the operating system can show the window.

**Version:**  5.1

**Supported OS:**

* Windows
* Macintosh

**Arguments:**

| Name | Type | Description |
| - | - | - |
| canShow | boolean | Window can show |

**Return Value:**

True if successful, false otherwise.

### setContextMenu

Sets the context menu.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| menu | object | Object describing the menu |

NOTE: In order to use this feature *useNotificationArea*  option must be set to *true*  in the Window configuration.

**Example:**

```json theme={null}
// Build the context menu
skinWindow.setContextMenu(JSON.stringify([
    {
        "id": 0,
        "text": "hello"
    },
    {
        "id": 1,
        "text": "hello2",
        "subMenu": [
            {
                "id": 2,
                "text": "goodbye",
                "checked": true
            },
            {
                "id": 3,
                "text": "goodbye2"
            }
        ]
    }
]));
// To capture when the user selected a menu item:
notificationCenter.addInstanceObserver("SkinWindow", "ContextMenuSelect", skinWindow, function(sender, info) {
    if (info.id == 0) {
        console.log("hello");
    } else if (info.id == 1) {
        console.log("hello2");
    } else if (info.id == 2) {
        console.log("goodbye");
    } else if (info.id == 3) {
        console.log("goodbye2");
    }
});
// Show the window
skinWindow.show();
```

### setContextMenuSelect

Selects the context menu item.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | ID of the menu item |
| select | boolean | True if selected, false otherwise |

**Example:**

```json theme={null}
skinWindow.setContextMenuSelect(0, true);
```

### setCursor

Sets the cursor for the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| cursor | string | Type of cursor to display. All Platforms: auto default crosshair e-resize ew-resize n-resize ns-resize nodrop not-allowed pointer s-resize text w-resize Windows: allscroll help move ne-resize nw-resize nwse-resize sw-resize wait |

**Return Value:**

True if successful, false otherwise.

### setMinimizeToNotificationArea

Sets whether or not the window will minimize to the notification area.

**Version:**  3.6

**OS Support:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| minimizeToNotificationArea | boolean | Minimize to notification area |

**Return Value:**

True if successful, false otherwise.

### setMinSize

Sets the minimum size of the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| width | integer | Minimum width of the window greater than zero. |
| height | integer | Minimum height of the window greater than zero. |

**Return Value:**

True if successful, false otherwise.

### setNotificationAreaIcon

Sets the notification area icon for the window.

**Version:**  3.6

**OS Support:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | X coordinate of the icon in the sprite map. |
| y | integer | Y coordinate of the icon in the sprite map. |
| width | integer | Width of the icon in the sprite map. (0 to disable) |
| height | integer | Height of the icon in the sprite map. (0 to disable) |

**Return Value:**

True if successful, false otherwise.

### setOrigin

Sets the origin of the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | Desired X position of the window |
| y | integer | Desired Y position of the window |

**Return Value:**

True if successful, false otherwise.

### setSize

Sets the size of the window.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| width | integer | Desired width of the window. If the width specified is less than the minimum width, then the window will be resized to the minimum width. |
| height | integer | Desired height of the window If the height specified is less than the minimum height, then the window will be resized to the minimum height. |

**Return Value:**

True if successful, false otherwise.

**Changes:**

* 5.1 - Automatically adjusts for monitor's DPI

### setSmallIcon

Sets the small icon for the window. When disabled it shows the application icon.

**Version:**  3.6

**OS Support:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | X coordinate of the icon in the sprite map. |
| y | integer | Y coordinate of the icon in the sprite map. |
| width | integer | Width of the icon in the sprite map. (0 to disable) |
| height | integer | Height of the icon in the sprite map. (0 to disable) |

**Return Value:**

True if successful, false otherwise.

### setTaskbarOverlay

Sets the taskbar icon overlay.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| x | integer | X coordinate of the icon in the sprite map. |
| y | integer | Y coordinate of the icon in the sprite map. |
| width | integer | Width of the icon in the sprite map. (0 to disable) |
| height | integer | Height of the icon in the sprite map. (0 to disable) |

**Notes:**

* This function should be called after the window has first been shown.

**Return Value:**

True if successful, false otherwise.

### setTaskbarProgress

Sets the progress in the task bar.

**Version:**  5.1

**OS Support:**

Some operating systems may not support showing progress in the task bar.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| value | integer | Value of the progress (0-100) -1: Indeterminate (not supported on Linux) -2: Hide progress |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
var value = 0;
var progressTimerId = setInterval(function() {
     value += 1;
     if (value > 100) {
         clearInterval(progressTimerId);
         skinWindow.setTaskProgress(-2); // Hide
         return;
     }
     skinWindow.setTaskProgress(value);
}, 500);
```

### setTitle

Sets the title for the window.

**Version:**  3.6

### setUseNotificationArea

Sets whether or not the window shows an icon the notification area.

**Version:**  3.6

**OS Support:**

* Windows

**Arguments:**

| Name | Type | Description |
| - | - | - |
| useNotificationArea | boolean | Use notification area |

**Return Value:**

True if successful, false otherwise.

### setWindowFrame

Sets the type of window frame.

**Version:**  3.6

**Arguments:**

| Name | Type | Description | Default |
| - | - | - | - |
| windowFrame | string | Window frame type Borderless Popup Resizable Normal | Normal |

**Return Value:**

True if successful, false otherwise.

**Additional Notes:**

* If the specified windowFrame does not exist, it will default to Normal.

### show

Shows the window.

**Version:**  3.6

## SkinWindowNotify

Notifcation type enumeration for use with *skinWindow\.notify* .

| Name | Description |
| - | - |
| INFO | Info |
| WARNING | Warning |
| ERROR | Error |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |

## SkinWindowMessageBox

Message box type flags for use with *skinWindow\.messageBox* .

| Name | Description |
| - | - |
| OK | Ok button |
| CANCEL | Cancel button |
| YES | Yes button |
| NO | No button |
| INFO | Info icon |
| WARNING | Warning icon |
| ERROR | Error icon |

**Changes in 5.2:**

* Added info, warning, and error

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Elevation rights value |
| separator | string | Optional string separator |

## TextFileReader

Read a text file.

### createTextReader

Creates a new TextReader object.

**Version:**  3.6

**Example:**

```json theme={null}
var text = "", observers = [],
reader = createTextFileReader();
reader.setFileName(path);
observers.push(notificationCenter.addInstanceObserver("TextFileReader", "Read", reader, function(sender, info) {
    text += info.text;
}));
observers.push(notificationCenter.addInstanceObserver("TextFileReader", "Complete", reader, function(sender, info) {
    observers.forEach(function(observer) {
        observer.release();
    });
    if (!isNull(completeCallback)) {
        completeCallback(text);
    }
    reader.release();
}));
reader.start();
```

### getBufferSize

Gets the maximum size of the read buffer

**Version:**  3.6

### getBytesLeft

Gets the bytes left to read.

**Version:**  3.6

### getFileName

Gets the path to the file to read.

**Version:**  3.6

### getFileSize

Gets the size of the file.

**Version:**  3.6

### release

Releases the instance.

**Version:**  3.6

### setBufferSize

Sets the maximum size of the read buffer

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| bufferSize | integer | Maximum size of the buffer |

**Return Value:**

True if successful, false otherwise.

### setFileName

Sets the path of the file to read.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| fileName | string | Path of the text file |

**Return Value:**

True if successful, false otherwise.

### start

Starts reading the file.

**Version:**  3.6

## TextFileWriter

### close

Closes the file.

**Version:**  3.6

### createTextWriter

Creates a new TextWriter object.

**Version:**  3.6

```json theme={null}
var writer = createTextFileWriter();
if (writer.open("c:\\myfile.txt")) {
    writer.write("hello world");
    writer.close();
}
writer.release();
```

### open

Opens a file for writing.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| fileName | string | Path of the text file |

**Return Value:**

True if successful, false otherwise.

### release

Releases the instance.

**Version:**  3.6

### write

Writes a string to a file

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| value | string | String to write to the file |

**Return Value:**

Returns the number of bytes written.

## WebGet

### authorize

Validates whether or not a url matches hostname whitelist.

**Version:**  5.2

**Arguments:**

| Name | Type | Description |
| - | - | - |
| url | string | URL for check |

**Return Value:**

True if authorized, false otherwise.

**Example:**

```json theme={null}
valid = webGet.authorize("https://myurl.com/");
```

### redirect

Expands the string with using the redirect substitutes.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| flags | integer | Redirection flags used when redirecting |
| url | string | String to expand |

**Return Value:**

Returns the expanded string.

**Example:**

```json theme={null}
item.image = webGet.redirect(webGetRedirect.EXPAND, item.image);
```

### redirectAdd

Adds a webget url redirection entry.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Redirection unique name |
| flags | int | Redirection flags |
| mutable | bool | true allows redirect to be overwritten, false otherwise |
| pattern | string | Regular expression pattern |
| replacement | string | Regular expression replacement |
| compileOptions | int | Regular expression compile options |
| subOptions | int | Regular expression sub options |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
webGet.redirectAdd("appendMyUrl", webGetRedirect.NONE, false, "^(https:\\/\\/myurl\\.com.*)", "${1}?test=111", webGetPcreCompileOption.NONE, webGetPcreSubstituteOption.NONE);
// Appends ?test=111 to all urls that start with https://myurl.com/
webGet.redirectAdd("replaceMyUrl", webGetRedirect.NONE, false, "^(https:\\/\\/myurl\\.com\\/x\\.txt.*)", "https://mybetterurl.com/x.txt", webGetPcreCompileOption.NONE, webGetPcreSubstituteOption.NONE);
// Replaces one exact url with another
```

### redirectAddMacro

Adds a webget url redirection key/value macro.

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | Redirection key. |
| value | string | Redirection value. |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
webGet.redirectAddMacro("myHostname", "myhostname.com");
// Expanded if url contains macro - https://{myHostname}/x.txt
```

### redirectClearAll

Removes all URL redirections and macros.

**Version:**  5.1

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
webGet.redirectClearAll();
```

### redirectRemove

Removes a webget url redirection entry.

**Version:**  5.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| name | string | Redirection name |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
webGet.redirectRemove("findMe");
```

### redirectRemoveMacro

Removes a webget url redirection key/value macro

**Version:**  6.1

**Arguments:**

| Name | Type | Description |
| - | - | - |
| key | string | Redirection key. |

**Return Value:**

True if successful, false otherwise.

**Example:**

```json theme={null}
webGet.redirectRemoveMacro("myHostname");
```

## WebGetRedirect

Redirection flags

| Name | Description |
| - | - |
| NONE | None |
| EXPAND | Expand macros during redirect (only used when calling redirect, not when adding) |
| RESOURCE | Resource only redirect |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Redirection type value |
| separator | string | Optional separator |

## WebGetPcreCompileOption

Regular expression compile options

**Version:**  6.1

| Name | Description |
| - | - |
| NONE | None |
| ALLOWEMPTYCLASS | Expand macros during redirect (only used when calling redirect, not when adding) |
| ALTBSUX | Resource only redirect |
| ALTCIRCUMFLEX | Alternative handling of ^ in multiline mode |
| ALTVERBNAMES | Process backslashes in verb names |
| ANCHORED | Force pattern anchoring |
| CASELESS | Case insensitive matching |
| DOLLARENDONLY | \$ not to match newline at end |
| DOTALL | . matches anything including NL |
| DUPNAMES | Allow duplicate names for subpatterns |
| ENDANCHORED | Pattern can match only at end of subject |
| EXTENDED | Ignore white space and # comments |
| FIRSTLINE | Force matching to be before newline |
| LITERAL | Pattern characters are all literal |
| MATCHUNSETBACKREF | Match unset backreferences |
| MULTILINE | ^ and \$ match newlines within data |
| NEVERBACKSLASHC | Lock out the use of \C in patterns |
| NOAUTOCAPTURE | Disable numbered capturing parentheses (named ones available) |
| NOAUTOPOSSESS | Disable auto-possessification |
| NODOTSTARANCHOR | Disable automatic anchoring for .\* |
| NOSTARTOPTIMIZE | Disable match-time start optimizations |
| UNGREEDY | Invert greediness of quantifiers |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Redirection type value |
| separator | string | Optional separator |

## WebGetPcreSubstituteOption

Regular expression substitute options

**Version:**  6.1

| Name | Description |
| - | - |
| NONE | None |
| ANCHORED | Force pattern anchoring |
| DUPNAMES | Allow duplicate names for subpatterns |
| ENDANCHORED | Pattern can match only at end of subject |
| NOTBOL | Subject is not the end of a line |
| NOTEOL | Force matching to be before newline |
| NOTEMPTY | An empty string is not a valid match |
| NOTEMPTYATSTART | An empty string at the start of the subject is not a valid match |
| EXTENDED | Do extended replacement processing |
| GLOBAL | Replace all occurrences in the subject |
| LITERAL | The replacement string is literal |
| REPLACEMENTONLY | Return only replacement string(s) |
| UNKNOWNUNSET | Treat unknown group as unset |
| UNSETEMPTY | Simple unset insert = empty string |

### nameFromId

Returns a string representing the specified enumeration value.

**Arguments:**

| Name | Type | Description |
| - | - | - |
| id | integer | Redirection type value |
| separator | string | optional separator |

## Wmi

**Version:**  5.2.0

**Supported OS:**

* Windows

### query

Querys the Windows Management Instrumentation.

**Version:**  3.6

**Arguments:**

| Name | Type | Description |
| - | - | - |
| server | string | Name of the server to query (for example root\cimv2) |
| query | string | WQL string to run |

**Return Value:**

Returns JSON results upon running the query or null upon failure.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.