Skip to content

service windows

Eric Busboom edited this page Sep 24, 2026 · 1 revision

Service on Windows (not hardware-verified)

The sc.exe commands install-service prints, the named pipe, and what is untested.

Service on Windows (not hardware-verified)

Not verified on real hardware. The Windows code (named-pipe local API, Service Control Manager integration, %ProgramData% paths) is covered only by unit tests with fakes. Nobody has run it against a real micro:bit on Windows. Expect rough edges, and please record what you find.

Install

py -3.12 -m venv C:\mbtools
C:\mbtools\Scripts\pip install "git+https://github.com/League-Microbit/mbtools.git"
C:\mbtools\Scripts\mbregistry install-service

On Windows, install-service writes no files. It prints these commands, which you then run in an Administrator shell. The binPath= is the interpreter that ran install-service:

sc.exe create mbregistry binPath= "C:\mbtools\Scripts\python.exe -m mbtools.registry.cli run --windows-service" start= auto DisplayName= "mbtools micro:bit registry daemon"
sc.exe failure mbregistry actions= restart/60000/restart/60000/restart/60000 reset= 86400
sc.exe start mbregistry
  • sc.exe needs the space after each name=.
  • failure restarts the service up to three times, 60 s apart, and resets the failure count after a day. This is the Windows analogue of systemd's Restart=on-failure.
  • --windows-service makes the process register with the SCM (StartServiceCtrlDispatcher). Without it, the SCM kills the process with error 1053. Don't use this flag interactively.

Where things are

Service name mbregistry (runs as LocalSystem, auto-start)
Database %ProgramData%\mbregistry\devices.db
Local API named pipe \\.\pipe\mbregistry (clients use it automatically)
TCP ports same as other platforms: 7440, 7442, 7443, 7444, 7445

Operate

sc.exe query mbregistry
sc.exe stop mbregistry
sc.exe start mbregistry
sc.exe delete mbregistry

Logs: a service's stdout/stderr are not captured anywhere. To see output, stop the service and run C:\mbtools\Scripts\mbregistry run in a console.

Firewall

New-NetFirewallRule -DisplayName "mbregistry TCP" -Direction Inbound -Protocol TCP -LocalPort 7440,7442,7443,7444,7445 -Action Allow
New-NetFirewallRule -DisplayName "mbregistry mDNS" -Direction Inbound -Protocol UDP -LocalPort 5353 -Action Allow

See Networking and peering for what each port does.

Upgrade

sc.exe stop mbregistry
C:\mbtools\Scripts\pip install --upgrade "git+https://github.com/League-Microbit/mbtools.git"
sc.exe start mbregistry

Clone this wiki locally