# ============================================================================== # BlockTheSpot-GUI.ps1 # Uso: irm https://tu-dominio.com/bts.ps1 | iex # github.com/mrpond/BlockTheSpot # ============================================================================== Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing [System.Windows.Forms.Application]::EnableVisualStyles() [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue' # ── Rutas ───────────────────────────────────────────────────────────────────── [System.Version]$MinVer = '1.2.8.923' $SpDir = Join-Path $env:APPDATA 'Spotify' $SpExe = Join-Path $SpDir 'Spotify.exe' $CElfDst = Join-Path $SpDir 'chrome_elf.dll' $CElfBak = Join-Path $SpDir 'chrome_elf_required.dll' $BtsDll = Join-Path $SpDir 'blockthespot.dll' $CfgIni = Join-Path $SpDir 'config.ini' $BaseUrl = 'https://github.com/mrpond/BlockTheSpot/releases/latest/download' $UrlElf = "$BaseUrl/chrome_elf.dll" $UrlBts = "$BaseUrl/blockthespot.dll" $UrlCfg = 'https://raw.githubusercontent.com/mrpond/BlockTheSpot/master/config.ini' # ── Colores ─────────────────────────────────────────────────────────────────── $cBg = [Drawing.Color]::FromArgb(18, 18, 18) $cDark = [Drawing.Color]::FromArgb(24, 24, 24) $cCard = [Drawing.Color]::FromArgb(32, 32, 32) $cGreen = [Drawing.Color]::FromArgb(30, 215, 96) $cBlue = [Drawing.Color]::FromArgb(100, 160, 255) $cRed = [Drawing.Color]::FromArgb(220, 70, 70) $cWhite = [Drawing.Color]::White $cGray = [Drawing.Color]::FromArgb(160, 160, 160) $cDGray = [Drawing.Color]::FromArgb(70, 70, 70) $cLogBg = [Drawing.Color]::FromArgb(10, 10, 10) $cYellow = [Drawing.Color]::FromArgb(255, 200, 60) $cBtn1Bg = [Drawing.Color]::FromArgb(28, 52, 36) $cBtn1Hov = [Drawing.Color]::FromArgb(38, 68, 46) $cBtn2Bg = [Drawing.Color]::FromArgb(22, 35, 58) $cBtn2Hov = [Drawing.Color]::FromArgb(32, 50, 78) $cBtn3Bg = [Drawing.Color]::FromArgb(50, 22, 22) $cBtn3Hov = [Drawing.Color]::FromArgb(66, 30, 30) # ============================================================================== # FORMULARIO # ============================================================================== $F = New-Object Windows.Forms.Form $F.Text = 'BlockTheSpot Installer' $F.ClientSize = New-Object Drawing.Size(520, 640) $F.StartPosition = 'CenterScreen' $F.BackColor = $cBg $F.FormBorderStyle = 'FixedSingle' $F.MaximizeBox = $false # ── Header ──────────────────────────────────────────────────────────────────── $pHead = New-Object Windows.Forms.Panel $pHead.Size = New-Object Drawing.Size(520, 86) $pHead.Location = New-Object Drawing.Point(0, 0) $pHead.BackColor = $cDark $F.Controls.Add($pHead) $lTitle = New-Object Windows.Forms.Label $lTitle.Text = ' BlockTheSpot' $lTitle.Font = New-Object Drawing.Font('Segoe UI', 18, [Drawing.FontStyle]::Bold) $lTitle.ForeColor = $cGreen $lTitle.BackColor = [Drawing.Color]::Transparent $lTitle.Location = New-Object Drawing.Point(14, 10) $lTitle.Size = New-Object Drawing.Size(310, 38) $pHead.Controls.Add($lTitle) $lSub = New-Object Windows.Forms.Label $lSub.Text = ' Adblocker para Spotify Desktop de Windows (64-bit)' $lSub.Font = New-Object Drawing.Font('Segoe UI', 8) $lSub.ForeColor = $cGray $lSub.BackColor = [Drawing.Color]::Transparent $lSub.Location = New-Object Drawing.Point(14, 52) $lSub.Size = New-Object Drawing.Size(430, 18) $pHead.Controls.Add($lSub) $lBadge = New-Object Windows.Forms.Label $lBadge.Text = 'v2026.02' $lBadge.Font = New-Object Drawing.Font('Segoe UI', 7, [Drawing.FontStyle]::Bold) $lBadge.ForeColor = $cBg $lBadge.BackColor = $cGreen $lBadge.Location = New-Object Drawing.Point(418, 16) $lBadge.Size = New-Object Drawing.Size(68, 18) $lBadge.TextAlign = 'MiddleCenter' $pHead.Controls.Add($lBadge) $lineG = New-Object Windows.Forms.Panel $lineG.Size = New-Object Drawing.Size(520, 2) $lineG.Location = New-Object Drawing.Point(0, 86) $lineG.BackColor = $cGreen $F.Controls.Add($lineG) # ── Estado ──────────────────────────────────────────────────────────────────── $pStat = New-Object Windows.Forms.Panel $pStat.Size = New-Object Drawing.Size(480, 48) $pStat.Location = New-Object Drawing.Point(20, 100) $pStat.BackColor = $cCard $F.Controls.Add($pStat) $lStatLbl = New-Object Windows.Forms.Label $lStatLbl.Text = 'Estado actual:' $lStatLbl.Font = New-Object Drawing.Font('Segoe UI', 7) $lStatLbl.ForeColor = $cGray $lStatLbl.BackColor = [Drawing.Color]::Transparent $lStatLbl.Location = New-Object Drawing.Point(10, 6) $lStatLbl.Size = New-Object Drawing.Size(460, 14) $pStat.Controls.Add($lStatLbl) $lStat = New-Object Windows.Forms.Label $lStat.Text = 'Verificando...' $lStat.Font = New-Object Drawing.Font('Segoe UI', 9, [Drawing.FontStyle]::Bold) $lStat.ForeColor = $cGray $lStat.BackColor = [Drawing.Color]::Transparent $lStat.Location = New-Object Drawing.Point(10, 22) $lStat.Size = New-Object Drawing.Size(460, 20) $pStat.Controls.Add($lStat) # ── Titulo opciones ─────────────────────────────────────────────────────────── $lOpts = New-Object Windows.Forms.Label $lOpts.Text = 'Selecciona una opcion:' $lOpts.Font = New-Object Drawing.Font('Segoe UI', 8, [Drawing.FontStyle]::Bold) $lOpts.ForeColor = $cGray $lOpts.Location = New-Object Drawing.Point(20, 162) $lOpts.Size = New-Object Drawing.Size(480, 18) $F.Controls.Add($lOpts) # ============================================================================== # BOTON 1 - Solo BlockTheSpot # ============================================================================== $p1 = New-Object Windows.Forms.Panel $p1.Size = New-Object Drawing.Size(480, 72) $p1.Location = New-Object Drawing.Point(20, 184) $p1.BackColor = $cBtn1Bg $p1.Cursor = [Windows.Forms.Cursors]::Hand $F.Controls.Add($p1) $p1.Controls.Add($( $x = New-Object Windows.Forms.Panel $x.Size = New-Object Drawing.Size(4, 72); $x.Location = New-Object Drawing.Point(0, 0) $x.BackColor = $cGreen; $x)) $p1.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = '>>'; $x.Font = New-Object Drawing.Font('Consolas', 16, [Drawing.FontStyle]::Bold) $x.ForeColor = $cGreen; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(14, 16); $x.Size = New-Object Drawing.Size(44, 32) $x.TextAlign = 'MiddleCenter'; $x)) $p1.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Solo instalar BlockTheSpot' $x.Font = New-Object Drawing.Font('Segoe UI', 10, [Drawing.FontStyle]::Bold) $x.ForeColor = $cWhite; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 10); $x.Size = New-Object Drawing.Size(400, 22); $x)) $p1.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Aplica el parche a la instalacion actual de Spotify' $x.Font = New-Object Drawing.Font('Segoe UI', 8) $x.ForeColor = $cGray; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 34); $x.Size = New-Object Drawing.Size(400, 18); $x)) $p1.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = ' RECOMENDADO ' $x.Font = New-Object Drawing.Font('Segoe UI', 7, [Drawing.FontStyle]::Bold) $x.ForeColor = $cGreen; $x.BackColor = [Drawing.Color]::FromArgb(20, 80, 40) $x.Location = New-Object Drawing.Point(66, 54); $x.Size = New-Object Drawing.Size(92, 14) $x.TextAlign = 'MiddleCenter'; $x)) $p1.Add_MouseEnter({ $p1.BackColor = $cBtn1Hov }) $p1.Add_MouseLeave({ $p1.BackColor = $cBtn1Bg }) foreach ($c in $p1.Controls) { $c.Add_MouseEnter({ $p1.BackColor = $cBtn1Hov }) $c.Add_MouseLeave({ $p1.BackColor = $cBtn1Bg }) } # ============================================================================== # BOTON 2 - Instalar Spotify + BlockTheSpot # ============================================================================== $p2 = New-Object Windows.Forms.Panel $p2.Size = New-Object Drawing.Size(480, 72) $p2.Location = New-Object Drawing.Point(20, 268) $p2.BackColor = $cBtn2Bg $p2.Cursor = [Windows.Forms.Cursors]::Hand $F.Controls.Add($p2) $p2.Controls.Add($( $x = New-Object Windows.Forms.Panel $x.Size = New-Object Drawing.Size(4, 72); $x.Location = New-Object Drawing.Point(0, 0) $x.BackColor = $cBlue; $x)) $p2.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = '[+]'; $x.Font = New-Object Drawing.Font('Consolas', 14, [Drawing.FontStyle]::Bold) $x.ForeColor = $cBlue; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(10, 18); $x.Size = New-Object Drawing.Size(50, 28) $x.TextAlign = 'MiddleCenter'; $x)) $p2.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Instalar Spotify + BlockTheSpot' $x.Font = New-Object Drawing.Font('Segoe UI', 10, [Drawing.FontStyle]::Bold) $x.ForeColor = $cWhite; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 10); $x.Size = New-Object Drawing.Size(400, 22); $x)) $p2.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Descarga Spotify Desktop y aplica el parche automaticamente' $x.Font = New-Object Drawing.Font('Segoe UI', 8) $x.ForeColor = $cGray; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 34); $x.Size = New-Object Drawing.Size(400, 18); $x)) $p2.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = ' INSTALACION LIMPIA ' $x.Font = New-Object Drawing.Font('Segoe UI', 7, [Drawing.FontStyle]::Bold) $x.ForeColor = $cBlue; $x.BackColor = [Drawing.Color]::FromArgb(18, 32, 65) $x.Location = New-Object Drawing.Point(66, 54); $x.Size = New-Object Drawing.Size(118, 14) $x.TextAlign = 'MiddleCenter'; $x)) $p2.Add_MouseEnter({ $p2.BackColor = $cBtn2Hov }) $p2.Add_MouseLeave({ $p2.BackColor = $cBtn2Bg }) foreach ($c in $p2.Controls) { $c.Add_MouseEnter({ $p2.BackColor = $cBtn2Hov }) $c.Add_MouseLeave({ $p2.BackColor = $cBtn2Bg }) } # ============================================================================== # BOTON 3 - Desinstalar # ============================================================================== $p3 = New-Object Windows.Forms.Panel $p3.Size = New-Object Drawing.Size(480, 72) $p3.Location = New-Object Drawing.Point(20, 352) $p3.BackColor = $cBtn3Bg $p3.Cursor = [Windows.Forms.Cursors]::Hand $F.Controls.Add($p3) $p3.Controls.Add($( $x = New-Object Windows.Forms.Panel $x.Size = New-Object Drawing.Size(4, 72); $x.Location = New-Object Drawing.Point(0, 0) $x.BackColor = $cRed; $x)) $p3.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = '[X]'; $x.Font = New-Object Drawing.Font('Consolas', 14, [Drawing.FontStyle]::Bold) $x.ForeColor = $cRed; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(10, 18); $x.Size = New-Object Drawing.Size(50, 28) $x.TextAlign = 'MiddleCenter'; $x)) $p3.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Desinstalar BlockTheSpot' $x.Font = New-Object Drawing.Font('Segoe UI', 10, [Drawing.FontStyle]::Bold) $x.ForeColor = $cWhite; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 10); $x.Size = New-Object Drawing.Size(400, 22); $x)) $p3.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = 'Elimina el parche y restaura Spotify al estado original' $x.Font = New-Object Drawing.Font('Segoe UI', 8) $x.ForeColor = $cGray; $x.BackColor = [Drawing.Color]::Transparent $x.Location = New-Object Drawing.Point(66, 34); $x.Size = New-Object Drawing.Size(400, 18); $x)) $p3.Controls.Add($( $x = New-Object Windows.Forms.Label $x.Text = ' REVERSIBLE ' $x.Font = New-Object Drawing.Font('Segoe UI', 7, [Drawing.FontStyle]::Bold) $x.ForeColor = $cRed; $x.BackColor = [Drawing.Color]::FromArgb(70, 22, 22) $x.Location = New-Object Drawing.Point(66, 54); $x.Size = New-Object Drawing.Size(72, 14) $x.TextAlign = 'MiddleCenter'; $x)) $p3.Add_MouseEnter({ $p3.BackColor = $cBtn3Hov }) $p3.Add_MouseLeave({ $p3.BackColor = $cBtn3Bg }) foreach ($c in $p3.Controls) { $c.Add_MouseEnter({ $p3.BackColor = $cBtn3Hov }) $c.Add_MouseLeave({ $p3.BackColor = $cBtn3Bg }) } # ── Log ─────────────────────────────────────────────────────────────────────── $pLog = New-Object Windows.Forms.Panel $pLog.Size = New-Object Drawing.Size(480, 110) $pLog.Location = New-Object Drawing.Point(20, 440) $pLog.BackColor = $cLogBg $F.Controls.Add($pLog) $rtLog = New-Object Windows.Forms.RichTextBox $rtLog.Size = New-Object Drawing.Size(478, 108) $rtLog.Location = New-Object Drawing.Point(1, 1) $rtLog.BackColor = $cLogBg $rtLog.ForeColor = $cGray $rtLog.Font = New-Object Drawing.Font('Consolas', 8) $rtLog.ReadOnly = $true $rtLog.BorderStyle = 'None' $rtLog.ScrollBars = 'Vertical' $pLog.Controls.Add($rtLog) # ── Progreso ────────────────────────────────────────────────────────────────── $pgBar = New-Object Windows.Forms.ProgressBar $pgBar.Size = New-Object Drawing.Size(480, 8) $pgBar.Location = New-Object Drawing.Point(20, 560) $pgBar.Minimum = 0; $pgBar.Maximum = 100; $pgBar.Value = 0 $pgBar.Style = 'Continuous' $F.Controls.Add($pgBar) # ── Footer ──────────────────────────────────────────────────────────────────── $lFoot = New-Object Windows.Forms.Label $lFoot.Text = 'github.com/mrpond/BlockTheSpot | Solo Spotify Desktop 64-bit' $lFoot.Font = New-Object Drawing.Font('Segoe UI', 7) $lFoot.ForeColor = $cDGray $lFoot.Location = New-Object Drawing.Point(20, 576) $lFoot.Size = New-Object Drawing.Size(480, 16) $lFoot.TextAlign = 'MiddleCenter' $F.Controls.Add($lFoot) # ============================================================================== # FUNCIONES # ============================================================================== function Log { param([string]$Msg, [string]$T = 'info') $ts = Get-Date -Format 'HH:mm:ss' $pre = switch ($T) { 'ok' { 'OK ' } 'warn' { 'WARN' } 'err' { 'ERR ' } 'step' { '... ' } default{ ' ' } } $col = switch ($T) { 'ok' { $cGreen } 'warn' { $cYellow } 'err' { $cRed } 'step' { $cBlue } default{ $cGray } } $rtLog.SelectionStart = $rtLog.TextLength $rtLog.SelectionLength = 0 $rtLog.SelectionColor = $cDGray $rtLog.AppendText("[$ts] ") $rtLog.SelectionColor = $col $rtLog.AppendText("$pre $Msg`n") $rtLog.ScrollToCaret() [Windows.Forms.Application]::DoEvents() } function Prog { param([int]$v) $pgBar.Value = [Math]::Min([Math]::Max($v, 0), 100) } function LockUI { param([bool]$on) $p1.Enabled = -not $on $p2.Enabled = -not $on $p3.Enabled = -not $on } function Confirm-Action { param([string]$msg, [string]$title) $r = [Windows.Forms.MessageBox]::Show( $msg, $title, [Windows.Forms.MessageBoxButtons]::YesNo, [Windows.Forms.MessageBoxIcon]::Question) return ($r -eq 'Yes') } function Show-Info { param([string]$msg, [string]$title) [Windows.Forms.MessageBox]::Show( $msg, $title, [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Information) | Out-Null } function Show-Warn { param([string]$msg, [string]$title) [Windows.Forms.MessageBox]::Show( $msg, $title, [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Warning) | Out-Null } function Show-Err { param([string]$msg, [string]$title) [Windows.Forms.MessageBox]::Show( $msg, $title, [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Error) | Out-Null } function Refresh-Status { $spInst = Test-Path $SpExe $btsOn = (Test-Path $CElfDst) -and (Test-Path $BtsDll) $isStore = $null -ne (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -EA SilentlyContinue) if ($isStore) { $lStat.ForeColor = $cYellow $lStat.Text = '! Spotify (Microsoft Store) — No compatible' } elseif (-not $spInst) { $lStat.ForeColor = $cGray $lStat.Text = 'o Spotify Desktop no instalado' } elseif ($btsOn) { $v = (Get-Item $SpExe).VersionInfo.ProductVersionRaw $lStat.ForeColor = $cGreen $lStat.Text = "+ Spotify $v | BlockTheSpot ACTIVO" } else { $v = (Get-Item $SpExe).VersionInfo.ProductVersionRaw $lStat.ForeColor = $cGray $lStat.Text = "o Spotify $v | BlockTheSpot no instalado" } } function Stop-Sp { Log 'Deteniendo Spotify...' 'step' Stop-Process -Name Spotify -EA SilentlyContinue Stop-Process -Name SpotifyWebHelper -EA SilentlyContinue Start-Sleep -Seconds 1 Log 'Spotify detenido.' 'ok' } function Get-WebFile { param([string]$Url, [string]$Out, [string]$Label) Log "Descargando $Label..." 'step' try { Invoke-WebRequest -Uri $Url -OutFile $Out -UseBasicParsing -EA Stop $kb = [math]::Round((Get-Item $Out).Length / 1KB, 1) Log "$Label OK ($kb KB)" 'ok' return $true } catch { Log "Error descargando $Label" 'err' return $false } } function Do-InstallBTS { foreach ($old in @( (Join-Path $SpDir 'dpapi.dll'), (Join-Path $SpDir 'blockthespot_settings.json') )) { if (Test-Path $old) { Remove-Item -Force $old $n = Split-Path $old -Leaf Log "Archivo antiguo eliminado: $n" 'warn' } } Log 'Verificando chrome_elf.dll original...' 'step' if (Test-Path $CElfBak) { Log 'Backup chrome_elf_required.dll ya existe.' 'ok' if (Test-Path $CElfDst) { $sz = (Get-Item $CElfDst).Length if ($sz -lt 1MB) { Remove-Item -Force $CElfDst } } } elseif (Test-Path $CElfDst) { $sz = (Get-Item $CElfDst).Length if ($sz -gt 1MB) { Rename-Item -Path $CElfDst -NewName 'chrome_elf_required.dll' -Force Log 'chrome_elf.dll original guardado como backup.' 'ok' } else { Remove-Item -Force $CElfDst Log 'chrome_elf.dll de BTS anterior eliminado.' 'warn' } } Prog 40 $r1 = Get-WebFile -Url $UrlElf -Out $CElfDst -Label 'chrome_elf.dll' Prog 65 $r2 = Get-WebFile -Url $UrlBts -Out $BtsDll -Label 'blockthespot.dll' Prog 85 $r3 = Get-WebFile -Url $UrlCfg -Out $CfgIni -Label 'config.ini' Prog 100 if (-not ($r1 -and $r2)) { Log 'Descarga fallida. Revisa tu conexion.' 'err' if ((-not (Test-Path $CElfDst)) -and (Test-Path $CElfBak)) { Rename-Item -Path $CElfBak -NewName 'chrome_elf.dll' -Force Log 'chrome_elf.dll original restaurado.' 'warn' } return $false } return $true } function Do-InstallSpotify { $setup = Join-Path $env:TEMP 'SpotifySetup.exe' $url = if ([Environment]::Is64BitOperatingSystem) { 'https://download.scdn.co/SpotifyFullSetupX64.exe' } else { 'https://download.scdn.co/SpotifyFullSetup.exe' } if (-not (Get-WebFile -Url $url -Out $setup -Label 'SpotifySetup.exe')) { return $false } Prog 20 Log 'Instalando Spotify...' 'step' $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) if ($isAdmin) { $act = New-ScheduledTaskAction -Execute 'powershell.exe' ` -Argument "-NoProfile -Command `"& '$setup'`"" $trg = New-ScheduledTaskTrigger -Once -At (Get-Date) $cfg = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries Register-ScheduledTask -Action $act -Trigger $trg -TaskName 'BTS_SpSetup' -Settings $cfg -Force | Out-Null Start-ScheduledTask -TaskName 'BTS_SpSetup' Start-Sleep -Seconds 3 Unregister-ScheduledTask -TaskName 'BTS_SpSetup' -Confirm:$false -EA SilentlyContinue } else { Start-Process -FilePath $setup } Log 'Esperando instalacion de Spotify...' 'step' $t = 0 while ($t -lt 120) { if (Get-Process -Name Spotify -EA SilentlyContinue) { break } Start-Sleep -Milliseconds 500 $t += 0.5 [Windows.Forms.Application]::DoEvents() } Start-Sleep -Seconds 2 Stop-Process -Name Spotify -EA SilentlyContinue Stop-Process -Name SpotifyWebHelper -EA SilentlyContinue Stop-Process -Name SpotifyFullSetupX64 -EA SilentlyContinue Stop-Process -Name SpotifyFullSetup -EA SilentlyContinue Start-Sleep -Seconds 2 if (-not (Test-Path $SpExe)) { Log 'No se pudo verificar la instalacion de Spotify.' 'err' return $false } Log 'Spotify instalado correctamente.' 'ok' return $true } # ============================================================================== # EVENTOS DE CLICK # ============================================================================== $clickB1 = { if (-not (Test-Path $SpExe)) { Show-Warn "Spotify Desktop no esta instalado.`nUsa la opcion 'Instalar Spotify + BlockTheSpot'." 'Spotify no encontrado' return } [System.Version]$v = (Get-Item $SpExe).VersionInfo.ProductVersionRaw if ($v -lt $MinVer) { $msg = "Spotify $v es anterior a la version minima requerida ($MinVer).`nPuede no funcionar. Continuar de todas formas?" if (-not (Confirm-Action $msg 'Version antigua')) { return } } if (-not (Confirm-Action "Se instalara BlockTheSpot.`nSpotify se cerrara durante el proceso. Continuar?" 'Instalar BlockTheSpot')) { return } LockUI $true; $rtLog.Clear(); Prog 0 Log 'Iniciando instalacion de BlockTheSpot...' 'step' Stop-Sp; Prog 15 $ok = Do-InstallBTS if ($ok) { Log 'BlockTheSpot instalado correctamente.' 'ok' Start-Process -WorkingDirectory $SpDir -FilePath $SpExe Refresh-Status Show-Info "BlockTheSpot instalado correctamente.`nSpotify se esta iniciando." 'Exito' } else { Show-Err "Hubo un error en la instalacion.`nRevisa el log para mas detalles." 'Error' } LockUI $false } $clickB2 = { if (-not (Confirm-Action "Se descargara e instalara Spotify Desktop y BlockTheSpot.`nSi tienes Spotify de la Store, sera desinstalado automaticamente.`n`nContinuar?" 'Instalacion completa')) { return } LockUI $true; $rtLog.Clear(); Prog 0 Log 'Iniciando instalacion completa...' 'step' if ($PSVersionTable.PSVersion.Major -ge 7) { Import-Module Appx -UseWindowsPowerShell -WA SilentlyContinue } if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic -EA SilentlyContinue) { Log 'Desinstalando Spotify Store...' 'warn' Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage Log 'Spotify Store desinstalado.' 'ok' } Stop-Sp; Prog 5 $ok = Do-InstallSpotify if (-not $ok) { Show-Err "No se pudo instalar Spotify.`nIntentalo manualmente desde spotify.com." 'Error' LockUI $false; return } Prog 30 Log 'Instalando BlockTheSpot...' 'step' Stop-Sp $ok = Do-InstallBTS if ($ok) { Log 'Instalacion completa exitosa.' 'ok' Start-Process -WorkingDirectory $SpDir -FilePath $SpExe Refresh-Status Show-Info "Spotify + BlockTheSpot instalados correctamente.`nSpotify se esta iniciando." 'Exito' } else { Show-Warn "Spotify se instalo pero BlockTheSpot fallo.`nRevisa el log." 'Error parcial' } LockUI $false } $clickB3 = { if (-not (Confirm-Action "Se eliminaran los archivos de BlockTheSpot y se restaurara chrome_elf.dll original.`n`nContinuar?" 'Desinstalar BlockTheSpot')) { return } LockUI $true; $rtLog.Clear(); Prog 0 Log 'Iniciando desinstalacion...' 'step' Stop-Sp; Prog 30 $removed = $false foreach ($f in @($CElfDst, $BtsDll, $CfgIni)) { if (Test-Path $f) { Remove-Item -Force $f $n = Split-Path $f -Leaf Log "Eliminado: $n" 'ok' $removed = $true } } Prog 70 if (Test-Path $CElfBak) { if (-not (Test-Path $CElfDst)) { Rename-Item -Path $CElfBak -NewName 'chrome_elf.dll' -Force Log 'chrome_elf.dll original restaurado.' 'ok' } else { Log 'chrome_elf.dll ya existia. Sin cambios.' 'warn' } } else { Log 'Backup no encontrado. Puede necesitar reinstalar Spotify.' 'warn' } Prog 100 if ($removed) { Log 'BlockTheSpot desinstalado correctamente.' 'ok' } else { Log 'No se encontraron archivos de BlockTheSpot instalados.' 'warn' } Start-Process -WorkingDirectory $SpDir -FilePath $SpExe -EA SilentlyContinue Refresh-Status Show-Info "BlockTheSpot desinstalado.`nSpotify restaurado al estado original." 'Desinstalacion completa' LockUI $false } $p1.Add_Click($clickB1); foreach ($c in $p1.Controls) { $c.Add_Click($clickB1) } $p2.Add_Click($clickB2); foreach ($c in $p2.Controls) { $c.Add_Click($clickB2) } $p3.Add_Click($clickB3); foreach ($c in $p3.Controls) { $c.Add_Click($clickB3) } # ============================================================================== # ARRANQUE # ============================================================================== $F.Add_Shown({ Log 'BlockTheSpot Installer iniciado.' 'info' $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) if ($isAdmin) { Log 'Ejecutando como Administrador.' 'ok' } else { Log 'ADVERTENCIA: No eres Administrador. Algunas operaciones pueden fallar.' 'warn' } Log 'Verificando estado de Spotify...' 'step' Refresh-Status Log 'Listo.' 'ok' }) [Windows.Forms.Application]::Run($F)