<# OMP Studio installer for Windows (PowerShell 5.1+, i.e. any Windows 10/11). The install command is shown at https://omp-studio.coderai.dev Installs a private, portable Node.js runtime plus the @omp-studio/omps agent into %LOCALAPPDATA%\omp-studio - no admin rights, no system-wide Node.js. System integration (the `omps` command on the user PATH and the right-click "Edit in OMP Studio" entry for .omp files) is then performed by the agent itself: `omps setup-windows`. The default double-click action of .omp files is left untouched, so Object Manager keeps working exactly as before. Re-running the installer updates Node and the agent to the latest versions. Uninstall: omps uninstall-windows #> $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" # much faster Invoke-WebRequest on PS 5.1 # Old Windows 10 builds default PS 5.1 to TLS 1.0; nodejs.org and npmjs need 1.2. [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $Root = Join-Path $env:LOCALAPPDATA "omp-studio" $NodeDir = Join-Path $Root "node" $AppDir = Join-Path $Root "app" Write-Host "" Write-Host "OMP Studio installer" -ForegroundColor Cyan Write-Host "Install folder: $Root" Write-Host "" switch ($env:PROCESSOR_ARCHITECTURE) { "AMD64" { $arch = "x64" } "ARM64" { $arch = "arm64" } default { throw "Unsupported CPU architecture '$($env:PROCESSOR_ARCHITECTURE)' - OMP Studio needs 64-bit Windows." } } # --- 1. portable Node.js LTS -------------------------------------------------- Write-Host "Checking the latest Node.js LTS version..." $releases = Invoke-RestMethod -Uri "https://nodejs.org/dist/index.json" -UseBasicParsing $lts = $releases | Where-Object { $_.lts } | Select-Object -First 1 if (-not $lts) { throw "Could not determine the latest Node.js LTS release." } $nodeVersion = $lts.version # e.g. v22.17.0 $nodeExe = Join-Path $NodeDir "node.exe" $haveVersion = $null if (Test-Path $nodeExe) { $haveVersion = (& $nodeExe -v) } if ($haveVersion -eq $nodeVersion) { Write-Host "Node.js $nodeVersion already installed - skipping download." } else { $zipName = "node-$nodeVersion-win-$arch" $tmpZip = Join-Path $env:TEMP "omp-studio-node.zip" $tmpDir = Join-Path $env:TEMP "omp-studio-node-unzip" Write-Host "Downloading Node.js $nodeVersion ($arch)... (~30 MB)" Invoke-WebRequest -Uri "https://nodejs.org/dist/$nodeVersion/$zipName.zip" -OutFile $tmpZip -UseBasicParsing Write-Host "Unpacking..." if (Test-Path $tmpDir) { Remove-Item $tmpDir -Recurse -Force } Expand-Archive -Path $tmpZip -DestinationPath $tmpDir -Force if (Test-Path $NodeDir) { Remove-Item $NodeDir -Recurse -Force } New-Item -ItemType Directory -Path $Root -Force | Out-Null Move-Item -Path (Join-Path $tmpDir $zipName) -Destination $NodeDir Remove-Item $tmpZip -Force Remove-Item $tmpDir -Recurse -Force Write-Host "Node.js $nodeVersion installed." } # --- 2. the OMP Studio agent (@omp-studio/omps) -------------------------------- Write-Host "Installing the OMP Studio agent (@omp-studio/omps)..." New-Item -ItemType Directory -Path $AppDir -Force | Out-Null $pkgJson = Join-Path $AppDir "package.json" if (-not (Test-Path $pkgJson)) { Set-Content -Path $pkgJson -Value '{ "name": "omp-studio-install", "private": true }' -Encoding Ascii } $npmCmd = Join-Path $NodeDir "npm.cmd" Push-Location $AppDir try { & $npmCmd install "@omp-studio/omps@latest" --prefer-online --no-audit --no-fund --loglevel=error if ($LASTEXITCODE -ne 0) { throw "npm install failed (exit code $LASTEXITCODE)." } } finally { Pop-Location } $ompsJs = Join-Path $AppDir "node_modules\@omp-studio\omps\bin\omps.js" if (-not (Test-Path $ompsJs)) { throw "Installation looks broken: $ompsJs not found." } # --- 3. system integration (PATH, context menu) - done by the agent itself ----- & $nodeExe $ompsJs setup-windows if ($LASTEXITCODE -ne 0) { throw "omps setup-windows failed (exit code $LASTEXITCODE)." }