Commit 8bd7975
Rhys Sullivan
Windows: install the background service without Administrator
The Windows `executor install` / `executor service install` always required
an elevated PowerShell. It registered the daemon as a boot-triggered Scheduled
Task (AtStartup + S4U + RunLevel Highest), and Task Scheduler only lets an
Administrator create that shape. macOS (launchd RunAtLoad) and Linux
(systemd --user) both install per-user with no elevation, so Windows was the
odd one out.
Default to a per-user logon task instead: a LogonTrigger + InteractiveToken
principal at LeastPrivilege, which a standard user may register for themselves.
This matches the launchd/systemd behavior (start at login, unprivileged). The
old boot-before-login behavior is preserved behind an explicit `--boot` flag,
which still needs an Administrator shell and says so.
Register via schtasks.exe rather than the PowerShell *-ScheduledTask cmdlets.
Those cmdlets reach Task Scheduler over CIM/DCOM, whose local-activation check
fails with Access denied (0x80070005) when the compiled binary spawns the
helper on a non-interactive window station; schtasks uses Task Scheduler RPC and
has no such dependency. status/uninstall/restart and the orphaned-listener
cleanup move off CIM too (schtasks query + netstat/taskkill).
A logon task runs in the user's interactive session, so launch the daemon
through a hidden wscript shim to avoid flashing a console window on the desktop
at every login; the shim waits on the wrapper so the task stays Running and
RestartOnFailure is preserved.
Verified on Windows Server 2022 as a standard, non-admin user: `--boot` is
correctly refused, the default install registers a logon task, the daemon comes
up, and /api/health returns 200.1 parent ffa4f70 commit 8bd7975
3 files changed
Lines changed: 378 additions & 178 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2794 | 2794 | | |
2795 | 2795 | | |
2796 | 2796 | | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
2797 | 2807 | | |
2798 | 2808 | | |
2799 | 2809 | | |
| |||
2807 | 2817 | | |
2808 | 2818 | | |
2809 | 2819 | | |
2810 | | - | |
| 2820 | + | |
2811 | 2821 | | |
2812 | 2822 | | |
2813 | 2823 | | |
| |||
2824 | 2834 | | |
2825 | 2835 | | |
2826 | 2836 | | |
2827 | | - | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
2828 | 2843 | | |
2829 | 2844 | | |
2830 | 2845 | | |
| |||
2881 | 2896 | | |
2882 | 2897 | | |
2883 | 2898 | | |
2884 | | - | |
| 2899 | + | |
2885 | 2900 | | |
2886 | 2901 | | |
2887 | 2902 | | |
| |||
2904 | 2919 | | |
2905 | 2920 | | |
2906 | 2921 | | |
2907 | | - | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
2908 | 2927 | | |
2909 | 2928 | | |
2910 | 2929 | | |
2911 | 2930 | | |
2912 | 2931 | | |
2913 | 2932 | | |
2914 | 2933 | | |
| 2934 | + | |
2915 | 2935 | | |
2916 | | - | |
| 2936 | + | |
2917 | 2937 | | |
2918 | 2938 | | |
2919 | 2939 | | |
| |||
2996 | 3016 | | |
2997 | 3017 | | |
2998 | 3018 | | |
| 3019 | + | |
2999 | 3020 | | |
3000 | | - | |
| 3021 | + | |
3001 | 3022 | | |
3002 | 3023 | | |
3003 | 3024 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
132 | 133 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
139 | 146 | | |
140 | 147 | | |
141 | | - | |
142 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
143 | 175 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
149 | 190 | | |
150 | 191 | | |
151 | 192 | | |
| |||
0 commit comments