@josephuspaye/launch-start-app
v0.1.0
Published
Launch apps from the Start Menu retrieved by @josephuspaye/start-apps.
Downloads
4
Readme
launch-start-app
Launch apps from the Start Menu retrieved by @josephuspaye/start-apps.
This project is part of #CreateWeekly, my attempt to create something new publicly every week in 2020.
Installation
npm install -g @josephuspaye/launch-start-app
Examples
Launch an app
The following program gets the first app from the Start Menu using @josephuspaye/start-apps and launches it:
import { getApps } from '@josephuspaye/start-apps';
import { launch } from '@josephuspaye/launch-start-app';
async function main() {
const apps = await getApps();
const launcherExitCode = await launch(apps[0]);
console.log(launcherExitCode); // 0 on a successful launch
}
main();
Launch a classic app as administrator
The following program finds Notepad using @josephuspaye/start-apps and launches it as administrator:
import { getApps } from '@josephuspaye/start-apps';
import { launch } from '@josephuspaye/launch-start-app';
async function main() {
const apps = await getApps();
const notepad = apps.find((app) => app.name === 'Notepad');
if (notepad) {
const launcherExitCode = await launch(notepad, { runAsAdmin: true });
console.log(launcherExitCode); // 0 on a successful launch
}
}
main();
API
interface ClassicApp {
type: 'classic';
appUserModelId: string;
targetPath: string;
targetArguments: string;
startMenuLink?: string;
[others: string]: any;
}
interface StoreApp {
type: 'store';
appUserModelId: string;
[others: string]: any;
}
/**
* Launch the given store app. Returns a Promise that resolves with the
* exit code of the launching process (not the app launched).
*/
function launch(app: StoreApp): Promise<number | null>;
/**
* Launch the given classic app, optionally as an administrator. Returns a
* Promise that resolves with the exit code of the launching process (not
* the app launched).
*/
function launch(
app: ClassicApp,
options?: { runAsAdmin: boolean }
): Promise<number | null>;