@slimio/winservices
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.0 • Public • Published

    Winservices

    version N-API Maintenance mit dep size Known Vulnerabilities Build Status Greenkeeper badge

    SlimIO Windows Services is a Node.js Binding which expose low-level Microsoft APIs to fetch Services state, configuration and triggers.

    The binding expose the following methods/struct:

    Requirements

    Getting Started

    This package is available in the Node Package Repository and can be easily installed with npm or yarn.

    $ npm i @slimio/winservices
    # or 
    $ yarn add @slimio/winservices

    Usage example

    Get all active windows services and retrieve advanced informations for each of them in series.

    const services = require("@slimio/winservices");
    const { States } = services.constants;
     
    async function main() {
        const activeServices = await services.enumServicesStatus(States.Active);
     
        for (const service of activeServices) {
            console.log(`service name: ${service.name}`);
            const serviceConfig = await services.getServiceConfiguration(service.name);
            console.log(JSON.stringify(serviceConfig, null, 4));
            console.log("------------------------------\n");
        }
    }
    main().catch(console.error);

    API

    enumServicesStatus(desiredState: number): Promise< Service[] >

    Enumerate Windows Services by the desirate state (Default equal to State.All). State can be retrieved with the constants State.

    export interface ServiceStates {
        Active: 0,
        Inactive: 1,
        All: 2
    }

    The returned value is a Promise that contain an Array of Service.

    export interface Service {
        name: string,
        displayName: string;
        process: {
            id?: number;
            name?: string;
            currentState: number;
            serviceType: number;
            checkPoint?: number;
            controlsAccepted: number;
            serviceFlags?: number;
            serviceSpecificExitCode: number;
            waitHint: number;
            win32ExitCode: number;
        };
    }
    enumDependentServices(serviceName: string, desiredState?: number): Promise< DependentServices >

    Enumerate dependent Windows Services of a given Service name. The returned value is a Promise of Object DependentServices.

    Default value for desiredState is State.All.

    export interface DependentServices {
        [serviceName: string]: Service;
    }

    Warning: Each Service are a reducted version of the TypeScript interface Service (optionals are not in the payload).

    getServiceConfiguration(serviceName: string): Promise< ServiceInformation >

    Get a given Windows Service configuration. The returned value is a Promise of Object ServiceInformation.

    export interface ServiceInformation {
        type: string;
        startType: string;
        errorControl: string;
        binaryPath: string;
        account: string;
        loadOrderGroup?: string;
        tagId?: number;
        dependencies?: string;
        description?: string;
    }
    getServiceTriggers(serviceName: string): Promise< ServiceTrigger[] >

    Get all Service triggers for a given Service name. The returned value is a Promise that contain an Array of ServiceTrigger.

    export interface ServiceTrigger {
        type: number;
        action: number;
        guid: string;
        dataItems: ServiceTriggerSpecificDataItem[]
    }
     
    export interface ServiceTriggerSpecificDataItem {
        dataType: number;
        data?: string;
    }

    Contribution Guidelines

    To contribute to the project, please read the code of conduct and the guide for N-API compilation.

    Dependencies

    Name Refactoring Security Risk Usage
    node-addon-api ⚠️Major Low Node.js C++ addon api
    node-gyp-build ⚠️Major Low Node-gyp builder

    License

    MIT

    Install

    npm i @slimio/winservices

    DownloadsWeekly Downloads

    2

    Version

    1.3.0

    License

    MIT

    Unpacked Size

    271 kB

    Total Files

    12

    Last publish

    Collaborators

    • mcroquet
    • ahkrin
    • fraxken
    • alexandre.malaj