Execute
Launch an app, open a file, or open a URL using execute from the system module.
javascript
import { execute } from "system";Table of Contents
execute(target[, parameters, workingDir, show])
Executes a target through the OS shell.
Parameters
target- Type:
string - Required: Yes
- Description: Executable path, document/file path, folder path, or URL.
- Type:
parameters- Type:
string - Required: No
- Description: Command-line arguments passed when launching an executable.
- Type:
workingDir- Type:
string - Required: No
- Description: Working directory for the launched process.
- Type:
show- Type:
number - Required: No
- Default:
1(SW_SHOWNORMAL) - Description: Window show mode passed to the shell.
- Type:
Return Value
- Type:
boolean - Description:
trueif launch succeeded; otherwisefalse.
Errors
- Throws a
TypeErrorwhentargetis missing.
Example: Launch Notepad
javascript
import { execute } from "system";
const ok = execute("notepad.exe", "README.txt");
console.log("launched:", ok);Example: Open URL
javascript
import { execute } from "system";
execute("https://novadesk.pages.dev/");Example: Launch Hidden (Show Flag)
javascript
import { execute } from "system";
// 0 = SW_HIDE
execute("cmd.exe", "/c echo hello > out.txt", "C:\\temp", 0);