How to use the node-windows.elevate function in node-windows

To help you get started, we’ve selected a few node-windows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jon-hall / pm2-windows-service / test / integration.js View on Github external
'use strict';

const assert = require('assert'),
    util = require('util'),
    path = require('path'),
    co = require('co'),
    promisify = require('promisify-node'),
    exec = promisify(require('child_process').exec),
    node_win = require('node-windows'),
    elevate = promisify(node_win.elevate),
    Service = node_win.Service,
    fsx = promisify('fs-extra'),
    temp = require('temp').track(),
    mkdir_temp = promisify(temp.mkdir),
    sid = get_sid();

co(function*() {
    // We deploy everything to a temp dir to avoid creating daemon files in this repo
    let temp_dir = yield mkdir_temp('pm2-windows-service-test');

    // Use npm to install ourselves to the temp dir
    // First thing we need is a skeleton package.json in the temp dir (otherwise it doesn't install there)
    let pkg = { name: path.basename(temp_dir), version: '0.0.1' };
    yield fsx.writeJson(path.resolve(temp_dir, 'package.json'), pkg);

    // Now we can 'npm install' there
github jon-hall / pm2-windows-service / src / setup.js View on Github external
.map(key => new Promise((resolve, reject) => {
            node_windows.elevate(`SETX ${key} "${answers[key]}" /m`, err => {
                if(err) {
                    return reject(err);
                }

                resolve();
            });
        }));
github jon-hall / pm2-windows-service / src / uninstall.js View on Github external
'use strict';

const path = require('path'),
    co = require('co'),
    event = require('co-event'),
    promisify = require('util').promisify || require('promisify-node'),
    fsx = require('fs-extra'),
    exec = promisify(require('child_process').exec),
    node_win = require('node-windows'),
    elevate = promisify(node_win.elevate),
    Service = node_win.Service,
    del = require('del'),
    common = require('./common'),
    save_dir = path.resolve(process.env.APPDATA, 'pm2-windows-service'),
    sid_file = path.resolve(save_dir, '.sid'),
    MAX_KILL_CHECKS = 12,
    KILL_CHECK_DELAY = 5000;


module.exports = co.wrap(function*(name) {
    common.check_platform();

    yield common.admin_warning();

    let name_from_sid_file;
    try {
github webhintio / hint / packages / connector-edge / src / connector-edge-launcher.ts View on Github external
import { spawn } from 'child_process';
import * as fs from 'fs';
import * as net from 'net';
import * as os from 'os';
import * as path from 'path';
import { promisify } from 'util';

import * as nodeWindows from 'node-windows';

import { debug as d, logger, misc } from '@hint/utils';
import { Launcher } from '@hint/utils-debugging-protocol-common';
import { BrowserInfo, LauncherOptions } from 'hint';

const { delay } = misc;
const diagnosticsPath = require.resolve('edge-diagnostics-adapter');
const elevate = promisify(nodeWindows.elevate);

const debug = d(__filename);

export class EdgeLauncher extends Launcher {
    private retryDelay: number = 500;

    public constructor(options: LauncherOptions) {
        super(options);
    }

    /** Removes all references to the client used by `isDebuggerReady`. */
    private cleanup(client: net.Socket) {
        client.removeAllListeners();
        client.end();
        client.destroy();
        client.unref();

node-windows

Support for Windows services, event logging, UAC, and several helper methods for interacting with the OS.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis