@@ -167,7 +167,6 @@ try {
167167# ---------------------------------------------------------------------------
168168
169169$launcherScript = Join-Path $BinDir ' prempti-launcher.ps1'
170- $installedFalco = Join-Path $BinDir ' falco.exe'
171170if (Test-Path $launcherScript ) {
172171 try {
173172 # Pass -Prefix so a custom install location picked via WixUI_InstallDir
@@ -191,65 +190,21 @@ if (Test-Path $launcherScript) {
191190# ---------------------------------------------------------------------------
192191# The Run key above only fires at next login. Bring the service up right
193192# now so the Claude Code hook we just registered has a live broker to talk
194- # to - otherwise fail-closed would block every tool call from the moment
195- # the MSI finishes until the user's next logout/login.
196- # Scope the detection by Path: a user running an unrelated Falco build in
197- # another directory should not convince us to skip the start.
198-
199- # Match by Path so unrelated falco.exe instances (other projects, dev
200- # builds) don't convince us to skip our own start. Guard .Path access
201- # with try/catch: on a process running under a different account it
202- # throws Win32Exception instead of returning $null, which would bubble
203- # past -ErrorAction SilentlyContinue.
204- function Test-InstalledFalcoRunning {
205- param ([string ]$TargetPath )
206- foreach ($p in Get-Process - Name falco - ErrorAction SilentlyContinue) {
207- try {
208- if ($p.Path -and ($p.Path -eq $TargetPath )) { return $true }
209- } catch {
210- # Access denied: not our process. Keep scanning.
211- }
193+ # to — otherwise fail-closed would block every tool call from the moment
194+ # the MSI finishes until the user's next logout/login. `premptictl start`
195+ # spawns the launcher detached, polls for readiness, and exits non-zero
196+ # with a pointer to the supervisor and Falco logs on failure.
197+ $startOk = $false
198+ if (Test-Path $ctlExe ) {
199+ & $ctlExe start
200+ $startOk = ($LASTEXITCODE -eq 0 )
201+ if (-not $startOk ) {
202+ Write-Warning " Service did not start. Run 'premptictl start' manually and check the supervisor and Falco logs under $LogDir ."
212203 }
213- return $false
214204}
215205
216- $falcoRunning = Test-InstalledFalcoRunning - TargetPath $installedFalco
217- if (-not $falcoRunning -and (Test-Path $launcherScript )) {
218- try {
219- # Pre-quote the path arguments. Start-Process -ArgumentList joins
220- # the array with bare spaces and does NOT quote elements that
221- # contain spaces, so a custom INSTALLDIR like "C:\Program
222- # Files\prempti" would otherwise be split before
223- # reaching the spawned powershell.
224- $quotedLauncher = ' "' + $launcherScript + ' "'
225- $quotedPrefix = ' "' + $Prefix + ' "'
226- $startArgs = @ (
227- ' -NoProfile' ,
228- ' -ExecutionPolicy' , ' Bypass' ,
229- ' -WindowStyle' , ' Hidden' ,
230- ' -File' , $quotedLauncher ,
231- ' -Prefix' , $quotedPrefix
232- )
233- Start-Process - FilePath ' powershell.exe' - ArgumentList $startArgs - WindowStyle Hidden | Out-Null
234- # Wait up to 5s for Falco to appear before declaring success.
235- $started = $false
236- for ($i = 0 ; $i -lt 20 ; $i ++ ) {
237- Start-Sleep - Milliseconds 250
238- if (Test-InstalledFalcoRunning - TargetPath $installedFalco ) {
239- $started = $true
240- break
241- }
242- }
243- if ($started ) {
244- Write-Host " Service started."
245- } else {
246- Write-Warning " Service start kicked off but Falco not detected yet. Check 'premptictl status' and the startup log at $LogDir \falco.err."
247- }
248- } catch {
249- Write-Warning " Could not start the service: $ ( $_.Exception.Message ) . Run 'premptictl start' manually and check $LogDir \falco.err."
250- }
251- } elseif ($falcoRunning ) {
252- Write-Host " Service already running."
206+ if ($startOk ) {
207+ Write-Host " Post-install complete: Prempti is installed, configured, and running."
208+ } else {
209+ Write-Host " Post-install complete: Prempti is installed and configured. The service is not running yet."
253210}
254-
255- Write-Host " Post-install complete: Prempti is installed, configured, and running."
0 commit comments