# StreamDeck Plugin Auto Deployment Script # Usage: Run .\deploy-plugin.ps1 in PowerShell Write-Host "========================================" -ForegroundColor Cyan Write-Host " StreamDeck Plugin Auto Deploy" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # Path settings $PluginSourcePath = "$PSScriptRoot\com.mirabox.streamingle.sdPlugin" $PluginDestPath = "$env:APPDATA\Hotspot\StreamDock\plugins\com.mirabox.streamingle.sdPlugin" $StreamDeckExe = "C:\Program Files\Hotspot\StreamDock\StreamDock.exe" # Check StreamDock executable path $StreamDeckExeFound = $false if (-not (Test-Path $StreamDeckExe)) { Write-Host "WARNING: StreamDock executable not found: $StreamDeckExe" -ForegroundColor Yellow Write-Host "Checking alternative paths..." -ForegroundColor Yellow # Check alternative paths $AlternativePaths = @( "C:\Program Files (x86)\Hotspot\StreamDock\StreamDock.exe", "C:\Program Files\Elgato\StreamDeck\StreamDeck.exe", "$env:ProgramFiles\Hotspot\StreamDock\StreamDock.exe", "${env:ProgramFiles(x86)}\Hotspot\StreamDock\StreamDock.exe", "$env:LOCALAPPDATA\Hotspot\StreamDock\StreamDock.exe", "$env:APPDATA\Hotspot\StreamDock\StreamDock.exe" ) foreach ($path in $AlternativePaths) { if (Test-Path $path) { $StreamDeckExe = $path $StreamDeckExeFound = $true Write-Host "SUCCESS: StreamDock executable found: $StreamDeckExe" -ForegroundColor Green break } } if (-not $StreamDeckExeFound) { Write-Host "WARNING: StreamDock executable not found!" -ForegroundColor Yellow Write-Host "Plugin files will be copied. Please restart StreamDock manually." -ForegroundColor Yellow } } else { $StreamDeckExeFound = $true } # Step 1: Stop StreamDock process Write-Host "Step 1: Stopping StreamDock process..." -ForegroundColor Yellow $StreamDeckProcess = Get-Process -Name "StreamDock" -ErrorAction SilentlyContinue if ($StreamDeckProcess) { Write-Host " StreamDock process found (PID: $($StreamDeckProcess.Id))" -ForegroundColor Gray try { Stop-Process -Name "StreamDock" -Force -ErrorAction Stop Start-Sleep -Seconds 2 Write-Host " SUCCESS: StreamDock process stopped" -ForegroundColor Green } catch { Write-Host " WARNING: Failed to stop process (permission issue)" -ForegroundColor Yellow Write-Host " Continuing... Please close StreamDock manually." -ForegroundColor Yellow Write-Host "" -ForegroundColor Yellow Write-Host " => Right-click StreamDock icon in taskbar -> Exit" -ForegroundColor Cyan Write-Host " => Press any key to continue after closing..." -ForegroundColor Cyan $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" } } else { Write-Host " INFO: StreamDock process is not running" -ForegroundColor Gray } Write-Host "" # Step 2: Backup and remove existing plugin folder Write-Host "Step 2: Cleaning up existing plugin folder..." -ForegroundColor Yellow if (Test-Path $PluginDestPath) { # Create backup folder $BackupPath = "$PluginDestPath.backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')" Write-Host " Backing up existing plugin: $BackupPath" -ForegroundColor Gray try { Move-Item -Path $PluginDestPath -Destination $BackupPath -Force Write-Host " SUCCESS: Existing plugin backed up" -ForegroundColor Green } catch { Write-Host " WARNING: Backup failed, attempting to delete..." -ForegroundColor Yellow Remove-Item -Path $PluginDestPath -Recurse -Force -ErrorAction SilentlyContinue } } else { Write-Host " INFO: No existing plugin found" -ForegroundColor Gray } # Ensure parent directory exists $PluginDestParent = Split-Path -Parent $PluginDestPath if (-not (Test-Path $PluginDestParent)) { Write-Host " Creating plugin directory: $PluginDestParent" -ForegroundColor Gray New-Item -ItemType Directory -Path $PluginDestParent -Force | Out-Null } Write-Host "" # Step 3: Copy new plugin Write-Host "Step 3: Copying new plugin..." -ForegroundColor Yellow if (-not (Test-Path $PluginSourcePath)) { Write-Host " ERROR: Source plugin folder not found: $PluginSourcePath" -ForegroundColor Red exit 1 } try { Write-Host " Copying from: $PluginSourcePath" -ForegroundColor Gray Write-Host " Copying to: $PluginDestPath" -ForegroundColor Gray Copy-Item -Path $PluginSourcePath -Destination $PluginDestPath -Recurse -Force # Count copied files $CopiedFiles = Get-ChildItem -Path $PluginDestPath -Recurse -File Write-Host " SUCCESS: Plugin copied ($($CopiedFiles.Count) files)" -ForegroundColor Green } catch { Write-Host " ERROR: Plugin copy failed: $_" -ForegroundColor Red exit 1 } Write-Host "" # Step 4: Restart StreamDock Write-Host "Step 4: Restarting StreamDock..." -ForegroundColor Yellow if ($StreamDeckExeFound) { try { Start-Process -FilePath $StreamDeckExe Write-Host " StreamDock started: $StreamDeckExe" -ForegroundColor Gray # Wait for process to start Start-Sleep -Seconds 3 $NewProcess = Get-Process -Name "StreamDock" -ErrorAction SilentlyContinue if ($NewProcess) { Write-Host " SUCCESS: StreamDock restarted (PID: $($NewProcess.Id))" -ForegroundColor Green } else { Write-Host " WARNING: Cannot verify StreamDock process (may be running in background)" -ForegroundColor Yellow } } catch { Write-Host " ERROR: StreamDock restart failed: $_" -ForegroundColor Red Write-Host " Please start StreamDock manually." -ForegroundColor Yellow } } else { Write-Host " WARNING: StreamDock executable not found, skipping auto-restart." -ForegroundColor Yellow Write-Host " Please restart StreamDock manually:" -ForegroundColor Yellow Write-Host " 1. Right-click StreamDock icon in taskbar -> Exit" -ForegroundColor Gray Write-Host " 2. Search 'StreamDock' in Start Menu and run" -ForegroundColor Gray } Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " Deployment Complete!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Cyan Write-Host "" Write-Host "Plugin has been updated." -ForegroundColor Green Write-Host "Check new actions in StreamDeck!" -ForegroundColor Green Write-Host "" # Auto-close after 5 seconds Write-Host "Auto-closing in 5 seconds..." -ForegroundColor Gray Start-Sleep -Seconds 5