Have ideas to improve npm?Join in the discussion! »

    @peterupton/elevator

    2.2.4 • Public • Published

    elevator

    Windows UAC elevation that just works.

    npm version dependencies

    Description

    This module is a thin wrapper around the awesome elevate.exe utility by kliu, which is a small C open source application with x64 and ia32 support that just works.

    This module doesn't make use of NodeJS C/C++ bindings and instead relies on executing the .exe file direcly in a way that is electron friendly even when the application is packaged in an asar archive.

    Of course, this means that this NodeJS module is subjected to the Windows versions and architectures such supports. Windows Vista (or newer) is required.

    Installation

    Install elevator by running:

    $ npm install --save elevator

    Documentation

    elevator.execute(command, [options], callback)

    This function will yield an Error containing a code that equals ELEVATE_CANCELLED if the elevation was cancelled by the user.

    Kind: static method of elevator Summary: Execute a command with UAC elevation Access: public

    Param Type Default Description
    command Array.<String> command
    [options] Object {} options
    [options.terminating] Boolean Launches a terminating command processor; equivalent to "cmd /c command".
    [options.persistent] Boolean Launches a persistent command processor; equivalent to "cmd /k command".
    [options.doNotPushdCurrentDirectory] Boolean When using -c or -k, do not pushd the current directory before execution.
    [options.unicode] Boolean When using -c or -k, use Unicode; equivalent to "cmd /u".
    [options.hidden] Boolean When using -c or -k, start "cmd" in hidden mode.
    [options.waitForTermination] Boolean Waits for termination; equivalent to "start /wait command".
    callback function callback (error, stdout, stderr)

    Example

    elevator.execute([ 'cmd.exe' ], {
      waitForTermination: true
    }, function(error, stdout, stderr) {
      if (error) {
        throw error;
      }
    
      console.log(stdout);
      console.log(stderr);
    });

    elevator.executeSync(command, [options]) ⇒ String

    This function will throw an Error containing a code that equals ELEVATE_CANCELLED if the elevation was cancelled by the user.

    Kind: static method of elevator Summary: Execute a command with UAC elevation (Sync) Returns: String - stdout buffer Access: public

    Param Type Default Description
    command Array.<String> command
    [options] Object {} options
    [options.terminating] Boolean Launches a terminating command processor; equivalent to "cmd /c command".
    [options.persistent] Boolean Launches a persistent command processor; equivalent to "cmd /k command".
    [options.doNotPushdCurrentDirectory] Boolean When using -c or -k, do not pushd the current directory before execution.
    [options.unicode] Boolean When using -c or -k, use Unicode; equivalent to "cmd /u".
    [options.hidden] Boolean When using -c or -k, start "cmd" in hidden mode.
    [options.waitForTermination] Boolean Waits for termination; equivalent to "start /wait command".

    Example

    elevator.executeSync([ 'cmd.exe' ], {
      waitForTermination: true
    });

    Support

    If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

    Tests

    Run the test suite by doing:

    $ gulp test

    Contribute

    Before submitting a PR, please make sure that you include tests, and that jshint runs without any warning:

    $ gulp lint

    License

    The project is licensed under the MIT license.

    Install

    npm i @peterupton/elevator

    DownloadsWeekly Downloads

    1

    Version

    2.2.4

    License

    MIT

    Unpacked Size

    1.01 MB

    Total Files

    26

    Last publish

    Collaborators

    • avatar