Fix Windows agent SC CREATE binPath quoting

The binPath parameter value needs outer quotes when it contains
embedded quotes and spaces. Without this, SC.EXE parses the value
incorrectly and fails to create the service.

Related to #776
This commit is contained in:
rcourtman 2025-11-28 18:04:24 +00:00
parent 806cdd2d87
commit 5a43ab4e57

View file

@ -315,7 +315,7 @@ if (-not [string]::IsNullOrWhiteSpace($AgentId)) { $ServiceArgs += @("--agent-id
$BinPath = "`"$DestPath`" $($ServiceArgs -join ' ')"
# Create Service with error handling
$scOutput = sc.exe create $AgentName binPath= $BinPath start= auto displayname= "Pulse Unified Agent" 2>&1
$scOutput = sc.exe create $AgentName binPath= "$BinPath" start= auto displayname= "Pulse Unified Agent" 2>&1
if ($LASTEXITCODE -ne 0) {
Show-Error "Failed to create service '$AgentName'.`nsc.exe output: $scOutput"
Exit 1