diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14fcb0d..4da899f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,12 +48,28 @@ jobs: Move-Item -Path "target\barn.exe" -Destination "target\${{ matrix.artifact }}.exe" -Force Get-ChildItem target\*.exe + - name: Build Windows installer + if: runner.os == 'Windows' + shell: pwsh + run: | + $version = "${{ github.ref_name }}" -replace '^v', '' + choco install innosetup -y + iscc /DAppVersion=$version installer\barn.iss + Get-ChildItem dist\*.exe + - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: target/${{ matrix.artifact }}* + - name: Upload Windows installer + if: runner.os == 'Windows' + uses: actions/upload-artifact@v4 + with: + name: windows-installer + path: dist/*.exe + release: needs: build-native runs-on: ubuntu-latest @@ -69,6 +85,9 @@ jobs: run: | mkdir release find artifacts -type f -exec mv {} release/ \; + # Add installer scripts + cp install.sh release/ + cp install.ps1 release/ cd release sha256sum * > SHA256SUMS ls -la diff --git a/README.md b/README.md index 9ef002e..0958c7a 100644 --- a/README.md +++ b/README.md @@ -42,57 +42,92 @@ This project treats FFmpeg jobs as **first-class managed units of work**, not sh ## Installation -### macOS +### Quick Install (Recommended) + +The installer scripts download the latest release, install the binary, and set up barn to run as a service on startup. + +**macOS / Linux:** +```bash +curl -fsSL https://raw.githubusercontent.com/samson-media/barn/main/install.sh | sh +``` + +**Windows (PowerShell as Administrator):** +```powershell +iwr -useb https://raw.githubusercontent.com/samson-media/barn/main/install.ps1 | iex +``` + +**Windows Installer (setup.exe):** + +Download the latest `setup-barn-vX.X.X-windows-x64.exe` from the [releases page](https://github.com/samson-media/barn/releases/latest). + +### Alternative Installation Methods + +#### macOS - Homebrew -**Homebrew (recommended):** ```bash brew install samson-media/tap/barn ``` -**Manual download:** +#### Manual Download + +**macOS (ARM64):** ```bash curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-macos-arm64 chmod +x barn sudo mv barn /usr/local/bin/ ``` -### Linux - -**Download the binary:** +**Linux (x64):** ```bash -# For x64 curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-linux-x64 - -# For ARM64 -curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-linux-arm64 - chmod +x barn sudo mv barn /usr/local/bin/ ``` -### Windows +**Linux (ARM64):** +```bash +curl -L -o barn https://github.com/samson-media/barn/releases/latest/download/barn-linux-arm64 +chmod +x barn +sudo mv barn /usr/local/bin/ +``` -**PowerShell (recommended):** +**Windows (PowerShell):** ```powershell -# Create install directory New-Item -ItemType Directory -Force -Path "$env:LOCALAPPDATA\Programs\barn" - -# Download Invoke-WebRequest -Uri "https://github.com/samson-media/barn/releases/latest/download/barn-windows-x64.exe" -OutFile "$env:LOCALAPPDATA\Programs\barn\barn.exe" - -# Add to PATH (current user) $path = [Environment]::GetEnvironmentVariable("Path", "User") if ($path -notlike "*$env:LOCALAPPDATA\Programs\barn*") { [Environment]::SetEnvironmentVariable("Path", "$path;$env:LOCALAPPDATA\Programs\barn", "User") } ``` -Restart your terminal after installation. +### Setting Up the Service (Manual Install) + +If you installed manually, you need to set up the service to run on startup: + +**Linux (systemd):** +```bash +barn service install +sudo systemctl enable barn +sudo systemctl start barn +``` + +**macOS (launchd):** +```bash +barn service install +``` + +**Windows (as Administrator):** +```powershell +barn service install +barn service start +``` ### Verify Installation ```bash barn --version +barn service status ``` --- diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..1a51510 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,269 @@ +# Barn Installer Script for Windows +# Usage: iwr -useb https://raw.githubusercontent.com/samson-media/barn/main/install.ps1 | iex +# +# This script installs the Barn job daemon and sets it up to run on startup. +# Requires: PowerShell 5.1+ and Administrator privileges (for Windows Service) + +param( + [switch]$NoService, + [string]$InstallDir = "$env:ProgramFiles\barn", + [string]$BarnDir = "$env:LOCALAPPDATA\barn" +) + +$ErrorActionPreference = "Stop" + +# Configuration +$Repo = "samson-media/barn" +$ServiceName = "barn" +$ServiceDisplayName = "Barn Job Daemon" + +function Write-Info { + param([string]$Message) + Write-Host "[INFO] " -ForegroundColor Green -NoNewline + Write-Host $Message +} + +function Write-Warn { + param([string]$Message) + Write-Host "[WARN] " -ForegroundColor Yellow -NoNewline + Write-Host $Message +} + +function Write-Err { + param([string]$Message) + Write-Host "[ERROR] " -ForegroundColor Red -NoNewline + Write-Host $Message + exit 1 +} + +function Test-Administrator { + $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() + $principal = New-Object Security.Principal.WindowsPrincipal($currentUser) + return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +function Get-LatestVersion { + Write-Info "Getting latest version..." + try { + $release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" + $version = $release.tag_name + Write-Info "Latest version: $version" + return $version + } + catch { + Write-Err "Failed to get latest version: $_" + } +} + +function Install-Binary { + param([string]$Version) + + $binaryName = "barn-windows-x64.exe" + $downloadUrl = "https://github.com/$Repo/releases/download/$Version/$binaryName" + + Write-Info "Downloading $binaryName..." + + # Create install directory + if (-not (Test-Path $InstallDir)) { + New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null + } + + $destPath = Join-Path $InstallDir "barn.exe" + + try { + # Download with progress + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $downloadUrl -OutFile $destPath -UseBasicParsing + $ProgressPreference = 'Continue' + } + catch { + Write-Err "Failed to download binary: $_" + } + + # Verify it works + try { + $versionOutput = & $destPath --version 2>&1 + Write-Info "Installed: $versionOutput" + } + catch { + Write-Err "Downloaded binary is not executable or corrupted" + } + + Write-Info "Installed barn to $destPath" + return $destPath +} + +function Add-ToPath { + param([string]$Directory) + + $currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine") + if ($currentPath -notlike "*$Directory*") { + Write-Info "Adding $Directory to system PATH..." + $newPath = "$currentPath;$Directory" + [Environment]::SetEnvironmentVariable("Path", $newPath, "Machine") + $env:Path = "$env:Path;$Directory" + Write-Info "Added to PATH. You may need to restart your terminal." + } + else { + Write-Info "$Directory is already in PATH" + } +} + +function Install-WindowsService { + param([string]$BinaryPath) + + Write-Info "Setting up Windows Service..." + + # Create barn data directory + if (-not (Test-Path $BarnDir)) { + New-Item -ItemType Directory -Path $BarnDir -Force | Out-Null + } + + # Check if service already exists + $existingService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue + if ($existingService) { + Write-Info "Stopping existing service..." + Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue + Write-Info "Removing existing service..." + sc.exe delete $ServiceName | Out-Null + Start-Sleep -Seconds 2 + } + + # Create the service using sc.exe + $binPath = "`"$BinaryPath`" service start --foreground --barn-dir `"$BarnDir`"" + + Write-Info "Creating service..." + $result = sc.exe create $ServiceName binPath= $binPath DisplayName= $ServiceDisplayName start= auto + if ($LASTEXITCODE -ne 0) { + Write-Err "Failed to create service: $result" + } + + # Set description + sc.exe description $ServiceName "Cross-platform job daemon for media processing" | Out-Null + + # Configure failure recovery (restart after 5 seconds) + sc.exe failure $ServiceName reset= 86400 actions= restart/5000/restart/5000/restart/5000 | Out-Null + + Write-Info "Service created: $ServiceName" + + # Start the service + Write-Info "Starting service..." + Start-Service -Name $ServiceName + + # Verify it's running + Start-Sleep -Seconds 2 + $service = Get-Service -Name $ServiceName + if ($service.Status -eq "Running") { + Write-Info "Service is running" + } + else { + Write-Warn "Service may not have started correctly. Status: $($service.Status)" + } +} + +function Install-ScheduledTask { + param([string]$BinaryPath) + + Write-Info "Setting up Scheduled Task (user mode)..." + + # Create barn data directory + if (-not (Test-Path $BarnDir)) { + New-Item -ItemType Directory -Path $BarnDir -Force | Out-Null + } + + $taskName = "BarnJobDaemon" + + # Remove existing task if present + $existingTask = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue + if ($existingTask) { + Write-Info "Removing existing scheduled task..." + Unregister-ScheduledTask -TaskName $taskName -Confirm:$false + } + + # Create action + $action = New-ScheduledTaskAction -Execute $BinaryPath -Argument "service start --foreground --barn-dir `"$BarnDir`"" + + # Create trigger (at logon) + $trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME + + # Create settings + $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) + + # Register task + Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Description "Barn Job Daemon" | Out-Null + + Write-Info "Scheduled task created: $taskName" + + # Start the task now + Write-Info "Starting barn..." + Start-ScheduledTask -TaskName $taskName + + Start-Sleep -Seconds 2 + Write-Info "Barn is running" +} + +function Main { + Write-Host "========================================" + Write-Host " Barn Installer for Windows" + Write-Host "========================================" + Write-Host "" + + $isAdmin = Test-Administrator + + if (-not $isAdmin) { + Write-Warn "Not running as Administrator." + Write-Warn "Will install for current user only (using Scheduled Task instead of Windows Service)." + Write-Host "" + + # Adjust install directory for non-admin + $InstallDir = Join-Path $env:LOCALAPPDATA "barn" + } + + Write-Info "Install directory: $InstallDir" + Write-Info "Data directory: $BarnDir" + Write-Host "" + + $version = Get-LatestVersion + $binaryPath = Install-Binary -Version $version + + if ($isAdmin) { + Add-ToPath -Directory $InstallDir + } + else { + # Add to user PATH + $currentPath = [Environment]::GetEnvironmentVariable("Path", "User") + if ($currentPath -notlike "*$InstallDir*") { + Write-Info "Adding $InstallDir to user PATH..." + $newPath = "$currentPath;$InstallDir" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") + $env:Path = "$env:Path;$InstallDir" + } + } + + if (-not $NoService) { + if ($isAdmin) { + Install-WindowsService -BinaryPath $binaryPath + } + else { + Install-ScheduledTask -BinaryPath $binaryPath + } + } + else { + Write-Info "Skipping service setup (use -NoService to disable)" + } + + Write-Host "" + Write-Host "========================================" + Write-Info "Barn installation complete!" + Write-Host "" + Write-Host "Commands:" + Write-Host " barn status - Show job status" + Write-Host " barn run -- - Run a command as a job" + Write-Host " barn service status - Show service status" + Write-Host "" + Write-Host "Data directory: $BarnDir" + Write-Host "========================================" +} + +# Run main +Main diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..b2b39e0 --- /dev/null +++ b/install.sh @@ -0,0 +1,307 @@ +#!/bin/sh +# Barn Installer Script +# Usage: curl -fsSL https://raw.githubusercontent.com/samson-media/barn/main/install.sh | sh +# +# This script installs the Barn job daemon and sets it up to run on startup. +# Supports: Linux (systemd), macOS (launchd) + +set -e + +# Configuration +REPO="samson-media/barn" +INSTALL_DIR="/usr/local/bin" +BARN_DIR="" # Will be set based on OS + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Print functions +info() { + printf "${GREEN}[INFO]${NC} %s\n" "$1" +} + +warn() { + printf "${YELLOW}[WARN]${NC} %s\n" "$1" +} + +error() { + printf "${RED}[ERROR]${NC} %s\n" "$1" + exit 1 +} + +# Detect OS +detect_os() { + case "$(uname -s)" in + Linux*) OS="linux" ;; + Darwin*) OS="macos" ;; + *) error "Unsupported operating system: $(uname -s)" ;; + esac +} + +# Detect architecture +detect_arch() { + case "$(uname -m)" in + x86_64|amd64) ARCH="x64" ;; + aarch64|arm64) ARCH="arm64" ;; + *) error "Unsupported architecture: $(uname -m)" ;; + esac +} + +# Get latest release version +get_latest_version() { + VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + if [ -z "$VERSION" ]; then + error "Failed to get latest version" + fi + info "Latest version: $VERSION" +} + +# Download and install binary +install_binary() { + BINARY_NAME="barn-${OS}-${ARCH}" + DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY_NAME}" + + info "Downloading $BINARY_NAME..." + + # Create temp directory + TMP_DIR=$(mktemp -d) + trap "rm -rf $TMP_DIR" EXIT + + # Download binary + if ! curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/barn"; then + error "Failed to download binary from $DOWNLOAD_URL" + fi + + # Make executable + chmod +x "$TMP_DIR/barn" + + # Verify it works + if ! "$TMP_DIR/barn" --version > /dev/null 2>&1; then + error "Downloaded binary is not executable or corrupted" + fi + + # Install to destination + if [ -w "$INSTALL_DIR" ]; then + mv "$TMP_DIR/barn" "$INSTALL_DIR/barn" + else + info "Installing to $INSTALL_DIR requires sudo..." + sudo mv "$TMP_DIR/barn" "$INSTALL_DIR/barn" + fi + + info "Installed barn to $INSTALL_DIR/barn" +} + +# Setup systemd service (Linux) +setup_systemd() { + info "Setting up systemd service..." + + # Determine if we should use user or system service + if [ "$(id -u)" -eq 0 ]; then + # Running as root - install system service + SERVICE_FILE="/etc/systemd/system/barn.service" + BARN_DIR="/var/lib/barn" + USER_MODE="" + SYSTEMCTL_CMD="systemctl" + else + # Running as user - install user service + SERVICE_FILE="$HOME/.config/systemd/user/barn.service" + BARN_DIR="$HOME/.local/share/barn" + USER_MODE="--user" + SYSTEMCTL_CMD="systemctl --user" + + # Create directory if needed + mkdir -p "$(dirname "$SERVICE_FILE")" + fi + + # Create barn data directory + mkdir -p "$BARN_DIR" + + # Generate service file + if [ -n "$USER_MODE" ]; then + # User service + cat > "$SERVICE_FILE" << EOF +[Unit] +Description=Barn Job Daemon (User) +Documentation=https://github.com/samson-media/barn + +[Service] +Type=simple +ExecStart=$INSTALL_DIR/barn service start --foreground --barn-dir $BARN_DIR +ExecStop=$INSTALL_DIR/barn service stop --barn-dir $BARN_DIR +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=default.target +EOF + else + # System service + sudo tee "$SERVICE_FILE" > /dev/null << EOF +[Unit] +Description=Barn Job Daemon +Documentation=https://github.com/samson-media/barn +After=network.target + +[Service] +Type=simple +ExecStart=$INSTALL_DIR/barn service start --foreground --barn-dir $BARN_DIR +ExecStop=$INSTALL_DIR/barn service stop --barn-dir $BARN_DIR +ExecReload=/bin/kill -HUP \$MAINPID +Restart=on-failure +RestartSec=5 + +# Security hardening +NoNewPrivileges=true +ProtectSystem=strict +ProtectHome=read-only +PrivateTmp=false +ReadWritePaths=$BARN_DIR + +# Logging +StandardOutput=journal +StandardError=journal +SyslogIdentifier=barn + +[Install] +WantedBy=multi-user.target +EOF + fi + + info "Created service file: $SERVICE_FILE" + + # Reload systemd + $SYSTEMCTL_CMD daemon-reload + + # Enable service + $SYSTEMCTL_CMD enable barn + info "Enabled barn service to start on boot" + + # Start service + $SYSTEMCTL_CMD start barn + info "Started barn service" + + # Show status + $SYSTEMCTL_CMD status barn --no-pager || true +} + +# Setup launchd service (macOS) +setup_launchd() { + info "Setting up launchd service..." + + # Always install as user agent on macOS + PLIST_FILE="$HOME/Library/LaunchAgents/com.samsonmedia.barn.plist" + BARN_DIR="$HOME/Library/Application Support/barn" + LOGS_DIR="$BARN_DIR/logs" + + # Create directories + mkdir -p "$(dirname "$PLIST_FILE")" + mkdir -p "$BARN_DIR" + mkdir -p "$LOGS_DIR" + + # Generate plist file + cat > "$PLIST_FILE" << EOF + + + + + Label + com.samsonmedia.barn + + ProgramArguments + + $INSTALL_DIR/barn + service + start + --foreground + --barn-dir + $BARN_DIR + + + RunAtLoad + + + KeepAlive + + + StandardOutPath + $LOGS_DIR/barn.log + + StandardErrorPath + $LOGS_DIR/barn.log + + WorkingDirectory + $BARN_DIR + + +EOF + + info "Created plist file: $PLIST_FILE" + + # Unload if already loaded (ignore errors) + launchctl unload "$PLIST_FILE" 2>/dev/null || true + + # Load the service + launchctl load "$PLIST_FILE" + info "Loaded barn service into launchd" + + # Start the service + launchctl start com.samsonmedia.barn + info "Started barn service" + + # Verify it's running + sleep 2 + if launchctl list | grep -q "com.samsonmedia.barn"; then + info "Barn service is running" + else + warn "Barn service may not have started correctly. Check logs at $LOGS_DIR/barn.log" + fi +} + +# Main installation function +main() { + echo "========================================" + echo " Barn Installer" + echo "========================================" + echo "" + + detect_os + detect_arch + info "Detected: $OS-$ARCH" + + get_latest_version + install_binary + + # Setup service based on OS + case "$OS" in + linux) + if [ -d "/run/systemd/system" ]; then + setup_systemd + else + warn "systemd not detected. Barn installed but not configured to run on startup." + warn "You can manually run: barn service start" + fi + ;; + macos) + setup_launchd + ;; + esac + + echo "" + echo "========================================" + info "Barn installation complete!" + echo "" + echo "Commands:" + echo " barn status - Show job status" + echo " barn run -- - Run a command as a job" + echo " barn service status - Show service status" + echo "" + echo "Data directory: $BARN_DIR" + echo "========================================" +} + +# Run main +main diff --git a/installer/barn.iss b/installer/barn.iss new file mode 100644 index 0000000..9291b2b --- /dev/null +++ b/installer/barn.iss @@ -0,0 +1,107 @@ +; Barn Installer Script for Inno Setup +; This script generates a Windows setup.exe installer +; Build: iscc barn.iss (requires Inno Setup 6+) + +#define AppName "Barn" +#define AppPublisher "Samson Media" +#define AppURL "https://github.com/samson-media/barn" +#define AppExeName "barn.exe" + +; Version is passed from CI: iscc /DAppVersion=0.1.0 barn.iss +#ifndef AppVersion + #define AppVersion "0.0.0" +#endif + +[Setup] +AppId={{7B8A9C5E-4D3F-2A1B-0E9D-8C7B6A5F4E3D} +AppName={#AppName} +AppVersion={#AppVersion} +AppVerName={#AppName} {#AppVersion} +AppPublisher={#AppPublisher} +AppPublisherURL={#AppURL} +AppSupportURL={#AppURL}/issues +DefaultDirName={autopf}\{#AppName} +DefaultGroupName={#AppName} +AllowNoIcons=yes +LicenseFile=..\LICENSE +OutputDir=..\dist +OutputBaseFilename=setup-barn-v{#AppVersion}-windows-x64 +Compression=lzma2 +SolidCompression=yes +WizardStyle=modern +PrivilegesRequired=admin +ArchitecturesAllowed=x64compatible +ArchitecturesInstallIn64BitMode=x64compatible +ChangesEnvironment=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "addtopath"; Description: "Add to PATH environment variable"; GroupDescription: "Additional options:" +Name: "installservice"; Description: "Install and start Windows Service"; GroupDescription: "Service options:"; Flags: checkedonce +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "..\target\barn-windows-x64.exe"; DestDir: "{app}"; DestName: "{#AppExeName}"; Flags: ignoreversion + +[Icons] +Name: "{group}\{#AppName} Status"; Filename: "{app}\{#AppExeName}"; Parameters: "status" +Name: "{group}\{#AppName} Service Status"; Filename: "{app}\{#AppExeName}"; Parameters: "service status" +Name: "{group}\Uninstall {#AppName}"; Filename: "{uninstallexe}" +Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon + +[Registry] +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ + ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \ + Tasks: addtopath; Check: NeedsAddPath('{app}') + +[Run] +Filename: "{app}\{#AppExeName}"; Parameters: "service install"; \ + StatusMsg: "Installing Windows Service..."; Tasks: installservice; Flags: runhidden +Filename: "{app}\{#AppExeName}"; Parameters: "service start"; \ + StatusMsg: "Starting Barn service..."; Tasks: installservice; Flags: runhidden + +[UninstallRun] +Filename: "{app}\{#AppExeName}"; Parameters: "service stop"; Flags: runhidden; RunOnceId: "StopService" +Filename: "{app}\{#AppExeName}"; Parameters: "service uninstall"; Flags: runhidden; RunOnceId: "UninstallService" + +[Code] +function NeedsAddPath(Param: string): boolean; +var + OrigPath: string; +begin + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, + 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', + 'Path', OrigPath) + then begin + Result := True; + exit; + end; + Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0; +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +var + Path: string; + AppPath: string; + P: Integer; +begin + if CurUninstallStep = usPostUninstall then + begin + if RegQueryStringValue(HKEY_LOCAL_MACHINE, + 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', + 'Path', Path) then + begin + AppPath := ExpandConstant('{app}'); + P := Pos(';' + AppPath, Path); + if P > 0 then + begin + Delete(Path, P, Length(';' + AppPath)); + RegWriteStringValue(HKEY_LOCAL_MACHINE, + 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', + 'Path', Path); + end; + end; + end; +end;