#requires -Version 7 $ErrorActionPreference = 'Stop' $Root = Resolve-Path (Join-Path $PSScriptRoot '..\..') Set-Location $Root if (-not $IsWindows) { Write-Error "wrong platform: $($PSVersionTable.OS) - use cargo xtask install" exit 1 } & (Join-Path $PSScriptRoot 'build.ps1') if ($LASTEXITCODE -ne 0) { throw "build.ps1 failed ($LASTEXITCODE)" } $Dest = if ($env:FEMM_INSTALL_DIR) { $env:FEMM_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\femm' } $Src = Join-Path $Root 'build\bin\femm' # Stop any running instance so the copy doesn't trip on a file lock. Get-Process -Name 'femm' -ErrorAction SilentlyContinue | ForEach-Object { Write-Host "Stopping running femm.exe (pid $($_.Id))..." try { $_ | Stop-Process -Force } catch {} } Start-Sleep -Milliseconds 200 if (Test-Path $Dest) { Remove-Item $Dest -Recurse -Force } New-Item -ItemType Directory -Force -Path $Dest | Out-Null Copy-Item -Path (Join-Path $Src '*') -Destination $Dest -Recurse -Force Write-Host "Installed: $Dest"