Skip to main content

Crate windows_services

Crate windows_services 

Source
Expand description

§windows-services

Implement a Windows service process with startup, status, and control callbacks. Installation and configuration belong to an installer or the Service Control Manager (SCM).

§Get started

[dependencies]
windows-services = "0.101"
windows_services::Service::new()
    .can_stop()
    .run(|_service, _command| {
        // Start or stop the application's workers here.
    })
    .unwrap();

The simple sample logs commands to a file. Running it outside the SCM prints installation commands. Register the executable’s absolute path, start it through the SCM, then stop and remove the test registration when finished. Registration normally needs administrative rights.

§Handle commands

Handle Command::Start and every enabled control. Keep callbacks responsive: start workers or signal them instead of running the main workload inside the callback. Stop workers and release resources during shutdown.

A service has a different account, working directory, and desktop context from an interactive application. Use absolute paths and a service-safe log destination, not console output.

Structs§

ExtendedCommand
A command not specifically covered by the Command enum.
Service
Configures and runs a Windows service.

Enums§

Command
A command sent by the service control manager.
State
A service state, including transitional states.