[PR #373] feat: windows service for uac+login support #392

Open
opened 2026-05-05 22:18:08 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/feschber/lan-mouse/pull/373
Author: @jonstelly
Created: 2/4/2026
Status: 🔄 Open

Base: mainHead: pr/windows-service


📝 Commits (10+)

📊 Changes

12 files changed (+1292 additions, -56 deletions)

View changed files

📝 Cargo.lock (+13 -0)
📝 Cargo.toml (+18 -0)
📝 input-emulation/Cargo.toml (+4 -0)
📝 input-emulation/src/windows.rs (+113 -5)
run.ps1 (+137 -0)
📝 src/config.rs (+44 -3)
📝 src/emulation.rs (+5 -1)
📝 src/lib.rs (+18 -0)
📝 src/main.rs (+122 -46)
📝 src/service.rs (+12 -1)
src/windows.rs (+236 -0)
src/windows_service.rs (+570 -0)

📄 Description

Support for installing and running lan-mouse as a windows service. This allows lan-mouse input on UAC elevation prompts and the login/unlock screens.

I'm flipping this PR out of draft mode but I imagine it will need some feedback and comments/direction for things to clean up before it's 100% ready to merge.

General architecture

  • lan-mouse can still be run directly on windows without installing/running the service. This will have the current limitation around not being able to control UAC elevation prompts or login/unlock screens, but still works exactly as it does today
  • lan-mouse can optionally run as service - The service is a sort of watchdog/orchestrator that will spawn individual lan-mouse daemon processes inside/attached-to user sessions with elevated permissions

Running/Testing

1a. build lan-mouse from the jonstelly:pr/windows-service branch
OR
1b. Download build from my fork
2. Copy ./target/debug files or extract the release zip file to a directory - c:\ProgramData\lan-mouse is a good option, this is where the config file and certificate will live
3. Launch an elevated terminal from the directory
4. Run lan-mouse install to install and start the windows service - If you already had a lan-mouse config file in your user's local-app-data lan-mouse directory, then the config and certificate will be copied into c:\ProgramData\lan-mouse with the install command, if not then the service will fail to start, you'll need to create the config.toml file in this directory now and then start the service

At this point, lan-mouse should be working in your normal windows desktop session, login screen, unlock screen, or UAC elevation prompts.

Looking for feedback

  • I added an "install" and "uninstall" CLI command to install the service in windows. In my head it feels like it would be nice to have 1 "install" command for each OS. For linux the install command could write the systemd user service file then enable it... For macos I understand there's launchd but I've never even looked into it. But the general thinking was that this could be the same command for install to make documenting process easy, even though on each OS, install means something different
  • For lan-mouse running as a service, it shouldn't attempt to load the config from a user's directory, so I adopted the recommended c:\ProgramData\lan-mouse directory for storing config and certificate. The install command above will look for a config.toml and lan-mouse.pem file in the user's lan-mouse config directory, if present in user path and not yet in ProgramData, then the install command will copy those files. It's not my favorite pattern, but it seems mostly intuitive, but open for any discussion here
  • Meta+l to lock a remote windows machine doesn't work. That's a secure action sequence, so I added special handling for windows emulation to catch Meta+l and lock the desktop. I tested this code both running lan-mouse as the windows service, and running it from non-elevated terminal, it seems to work in both cases
  • Added a handful of comments for different parts of code, specifically curious for input on the file logging, anything else
  • This is probably the most rust code I've put together in 1 PR so welcome any feedback, I know there's already some cleanup I want to do, but happy to hear about anything else

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/feschber/lan-mouse/pull/373 **Author:** [@jonstelly](https://github.com/jonstelly) **Created:** 2/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/windows-service` --- ### 📝 Commits (10+) - [`f8b90bf`](https://github.com/feschber/lan-mouse/commit/f8b90bf7afe59858ec24f4adbf4ebe5e40e13fdf) feat: windows service for uac+login support - [`58e04c5`](https://github.com/feschber/lan-mouse/commit/58e04c562ae3af63ebd35ed7e53140f44c547492) watchdog -> winsvc - [`7fec0a4`](https://github.com/feschber/lan-mouse/commit/7fec0a4540153ed836bda00f19cd977e9a1863e0) fix winsvc vs win-svc cmd - [`831987c`](https://github.com/feschber/lan-mouse/commit/831987c9c89138198267e8d28b4b3bb81a269804) Handle Meta+l to lock screen on windows - [`255aa40`](https://github.com/feschber/lan-mouse/commit/255aa4027736048c89271585ce9b47bc476f7607) minor cleanup - [`bd9f416`](https://github.com/feschber/lan-mouse/commit/bd9f41657aeff6cb88d4007f6ece2df688a5a392) init_logging comment - [`bc7d28a`](https://github.com/feschber/lan-mouse/commit/bc7d28a24763875a76d5c60e7ab8fdb4d9c79f35) windows service cleanup - [`fb31483`](https://github.com/feschber/lan-mouse/commit/fb314832115babc68795423421b5df2295689fdb) formatting fixes - [`684a829`](https://github.com/feschber/lan-mouse/commit/684a8295b01a6cdfc8c96127231205fab908d102) windows clippy fixes - [`9ddc443`](https://github.com/feschber/lan-mouse/commit/9ddc443021b3bc5dedd085129546e83f3a6bc648) fix formatting from clippy fixes ### 📊 Changes **12 files changed** (+1292 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+13 -0) 📝 `Cargo.toml` (+18 -0) 📝 `input-emulation/Cargo.toml` (+4 -0) 📝 `input-emulation/src/windows.rs` (+113 -5) ➕ `run.ps1` (+137 -0) 📝 `src/config.rs` (+44 -3) 📝 `src/emulation.rs` (+5 -1) 📝 `src/lib.rs` (+18 -0) 📝 `src/main.rs` (+122 -46) 📝 `src/service.rs` (+12 -1) ➕ `src/windows.rs` (+236 -0) ➕ `src/windows_service.rs` (+570 -0) </details> ### 📄 Description Support for installing and running lan-mouse as a windows service. This allows lan-mouse input on UAC elevation prompts and the login/unlock screens. I'm flipping this PR out of draft mode but I imagine it will need some feedback and comments/direction for things to clean up before it's 100% ready to merge. ## General architecture - lan-mouse can still be run directly on windows without installing/running the service. This will have the current limitation around not being able to control UAC elevation prompts or login/unlock screens, but still works exactly as it does today - lan-mouse can optionally run as service - The service is a sort of watchdog/orchestrator that will spawn individual lan-mouse daemon processes inside/attached-to user sessions with elevated permissions ## Running/Testing 1a. build lan-mouse from the [jonstelly:pr/windows-service](https://github.com/jonstelly/lan-mouse/tree/pr/windows-service) branch OR 1b. Download build from [my fork](https://github.com/jonstelly/lan-mouse/releases/tag/main) 2. Copy `./target/debug` files or extract the release zip file to a directory - `c:\ProgramData\lan-mouse` is a good option, this is where the config file and certificate will live 3. Launch an elevated terminal from the directory 4. Run `lan-mouse install` to install and start the windows service - If you already had a lan-mouse config file in your user's local-app-data lan-mouse directory, then the config and certificate will be copied into `c:\ProgramData\lan-mouse` with the install command, if not then the service will fail to start, you'll need to create the config.toml file in this directory now and then start the service At this point, lan-mouse should be working in your normal windows desktop session, login screen, unlock screen, or UAC elevation prompts. ## Looking for feedback - I added an "install" and "uninstall" CLI command to install the service in windows. In my head it feels like it would be nice to have 1 "install" command for each OS. For linux the install command could write the systemd user service file then enable it... For macos I understand there's launchd but I've never even looked into it. But the general thinking was that this could be the same command for install to make documenting process easy, even though on each OS, install means something different - For lan-mouse running as a service, it shouldn't attempt to load the config from a user's directory, so I adopted the recommended `c:\ProgramData\lan-mouse` directory for storing config and certificate. The install command above will look for a config.toml and lan-mouse.pem file in the user's lan-mouse config directory, if present in user path and not yet in ProgramData, then the install command will copy those files. It's not my favorite pattern, but it seems mostly intuitive, but open for any discussion here - Meta+l to lock a remote windows machine doesn't work. That's a secure action sequence, so I added special handling for windows emulation to catch Meta+l and lock the desktop. I tested this code both running lan-mouse as the windows service, and running it from non-elevated terminal, it seems to work in both cases - Added a handful of comments for different parts of code, specifically curious for input on the file logging, anything else - This is probably the most rust code I've put together in 1 PR so welcome any feedback, I know there's already some cleanup I want to do, but happy to hear about anything else --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror added the
pull-request
label 2026-05-05 22:18:09 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/lan-mouse#392
No description provided.