Launch process

UXP core APIs also offer shell APIs to launch processes in the user's system.

There are primarily two things you can do with the help of these APIs

  1. Open a file using the standard application. For example, open a PDF in Acrobat Reader.
  2. Launch applications. For example, open the mail client with an email address.

Before we take a look at some examples, you must know that these APIs are associated with the launchProcess permission in the manifest.

data-variant=info
data-slots=header, text1, text2
Plugins and Scripts
In plugins, you should specify the schemes and file extensions in the launchProcess permission in your manifest for it to work. IMPORTANT: Please read about the manifest permissions module before you proceed.
In scripts, the permission for launchProcess is fixed. You can ignore the manifest details in the following examples. Learn about these values in the manifest fundamentals section.

System requirements

Please make sure your local environment uses the following application versions before proceeding.

Opening a file

For opening a file, you must provide the full path of the file and specify the extensions of the files you are about to access in the plugin manifest.

Example

data-slots=heading, code
data-repeat=2
data-languages=JavaScript, JSON

JavaScript

async function foo() {
    const { shell }  = require("uxp");
    try {
        await shell.openPath("/Users/user/Desktop/test.pdf");
    } catch (e) {
        console.error(e);
    }
}

manifest

{
    "launchProcess": {
        "extensions": [".pdf"]
    }
}

User consent for open-path

Launch a process

You can open an application in the user's system with the help of URL Schemes

Example

data-slots=heading, code
data-repeat=2
data-languages=JavaScript, JSON

JavaScript

async function foo() {
    const { shell }  = require("uxp");
    try {
        await shell.openExternal("https://www.adobe.com", "Opening browser for testing purpose.");
        await shell.openExternal("mailto:/example.com/");
    } catch (e) {
        console.error(e);
    }
}

manifest

{
    "launchProcess": {
        "schemes": ["https", "mailto"]
    }
}

User consent for open external

Additional notes

Reference material