aboutsummaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
Diffstat (limited to 'packaging')
-rw-r--r--packaging/win/service.ps117
1 files changed, 12 insertions, 5 deletions
diff --git a/packaging/win/service.ps1 b/packaging/win/service.ps1
index 29a02fe..1f84a29 100644
--- a/packaging/win/service.ps1
+++ b/packaging/win/service.ps1
@@ -68,11 +68,18 @@ switch ($Action) {
"install" {
if (-not (Test-Path $node)) { throw "meshbay-node.exe not found at $node" }
$user = Get-CurrentUser
- $action = New-ScheduledTaskAction -Execute $node
- $trigger = New-ScheduledTaskTrigger -AtStartup
- $principal = New-ScheduledTaskPrincipal -UserId $user -LogonType S4U -RunLevel Limited
- Register-ScheduledTask -TaskName $TASK_NAME -Action $action -Trigger $trigger `
- -Principal $principal -Force -ErrorAction Stop | Out-Null
+ # NOT $action: PowerShell variable names are case-insensitive, so $action
+ # is this script's own [ValidateSet("install",...)][string]$Action
+ # parameter. Assigning the New-ScheduledTaskAction CimInstance to it
+ # runs the ValidateSet check (fails) and coerces the object to the
+ # string "MSFT_TaskExecAction", which Register-ScheduledTask -Action
+ # then rejects with "MSFT_TaskExecAction is not a valid value for the
+ # Action variable" -- the install path never actually created the task.
+ $taskAction = New-ScheduledTaskAction -Execute $node
+ $bootTrigger = New-ScheduledTaskTrigger -AtStartup
+ $taskPrincipal = New-ScheduledTaskPrincipal -UserId $user -LogonType S4U -RunLevel Limited
+ Register-ScheduledTask -TaskName $TASK_NAME -Action $taskAction -Trigger $bootTrigger `
+ -Principal $taskPrincipal -Force -ErrorAction Stop | Out-Null
Write-Host "service: installed ($user, runs at boot)"
}
"remove" {