Skip to content

Adds a Windows service example#3590

Merged
kennykerr merged 4 commits into
masterfrom
service-sample
May 2, 2025
Merged

Adds a Windows service example#3590
kennykerr merged 4 commits into
masterfrom
service-sample

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

This sample illustrates how to write a Windows service directly using the Service Control Manager (SCM) and with the help of the windows-sys crate. Once built, you can install the service (from an admin prompt) as follows:

> sc create rust binPath= D:\git\windows-rs\target\debug\sample_service_sys.exe

You can then use the various SCM commands to control the services:

> sc start rust
> sc pause rust
> sc continue rust
> sc stop rust

I do plan to provide a more idiomatic windows-services crate but this should help get you started if you need to write a Windows service for the time being.

@kennykerr
kennykerr requested a review from Copilot May 2, 2025 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new Windows service example written in Rust using the windows-sys crate. Key changes include:

  • A new sample implementation for a Windows service, including service control management and thread management.
  • Addition of a Cargo package configuration for the sample.
  • Updates to GitHub workflows to include tests for the new sample.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
crates/samples/windows-sys/service/src/main.rs Implements the Windows service sample with SCM integration and logging
crates/samples/windows-sys/service/Cargo.toml Adds package metadata and dependencies for the sample service
.github/workflows/test.yml Updates workflow to run tests for the newly added service sample

Comment thread crates/samples/windows-sys/service/src/main.rs
Comment thread crates/samples/windows-sys/service/src/main.rs
Comment thread crates/samples/windows-sys/service/src/main.rs
Comment thread crates/samples/windows-sys/service/src/main.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants