KEMBAR78
Adds a Windows service example by kennykerr · Pull Request #3590 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@kennykerr
Copy link
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
Copy link

Copilot AI left a comment

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

@kennykerr kennykerr merged commit 453134f into master May 2, 2025
29 checks passed
@kennykerr kennykerr deleted the service-sample branch May 2, 2025 16:28
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.

1 participant