#windows #service #run-time #environment #detection #running #detector

windows-service-detector

A Rust crate that provides Windows Service runtime environment detection

1 unstable release

0.1.0 Jun 28, 2023

#37 in #detector

Download history 144/week @ 2024-11-16 120/week @ 2024-11-23 144/week @ 2024-11-30 158/week @ 2024-12-07 134/week @ 2024-12-14 21/week @ 2024-12-21 26/week @ 2024-12-28 44/week @ 2025-01-04 53/week @ 2025-01-11 158/week @ 2025-01-18 224/week @ 2025-01-25 186/week @ 2025-02-01 141/week @ 2025-02-08 90/week @ 2025-02-15 126/week @ 2025-02-22 127/week @ 2025-03-01

502 downloads per month
Used in universal-service

MIT license

8KB
99 lines

windows-service-detector

A Rust crate that provides Windows Service runtime environment detection.

See the documentation library documentation.

Usage

See the provided example in examples/service.rs for a fully functional example.

TL;DR, in your main.rs you should do something like:

use windows_service_detector::is_running_as_windows_service;

fn main() {
    if is_running_as_windows_service().unwrap() {
        run_service();
    } else {
        println!("this is not a service");
    }
}

Running the Example

To demonstrate the example binary running as a normal command line program:

cargo run --example service

To demonstrate the same binary running as a Windows Service, use the provided test script in an Administrator command prompt:

.\example-service-test.ps1

Development

This crate is considered feature-complete, as its sole purpose is to provide Windows Service environment detection.

If you find a bug, please report it through the GitHub issue tracker for this repository.

Dependencies

~122MB
~2M SLoC