npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slimio/winservices

v1.3.0

Published

Windows Services - Node.JS low level binding

Downloads

8

Readme

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

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;
    };
}

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).

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;
}

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