@ahmic/autoit-js
    Preparing search index...

    Function RunAs

    • Runs a program under a different user account.

      Parameters

      • username: string

        The username to run the program as.

      • domain: string

        The domain of the user account.

      • password: string

        The password of the user account.

      • logonFlag: LogonFlag

        The logon flag to control the behavior of the logon.

      • program: string

        The name of the program to run.

      • directory: string = ''

        Optional working directory for the program.

      • showFlag: number = ShowWindowFlag.SHOWNORMAL

        Optional flag to control how the program's window is shown.

      Returns number

      The PID of the started process if successful, or 0 if failed.

      import { RunAs, LogonFlag } from '@ahmic/autoit-js';

      const pid = RunAs('admin', 'DOMAIN', 'password', LogonFlag.Profile, 'notepad.exe');

      console.log(pid); // Output: 123