diff --git a/Spotify.vbs b/Cache/Spotify.vbs similarity index 98% rename from Spotify.vbs rename to Cache/Spotify.vbs index bc753fb..23d1c32 100644 --- a/Spotify.vbs +++ b/Cache/Spotify.vbs @@ -1,3 +1,3 @@ -command = "powershell.exe -ExecutionPolicy Bypass -nologo -noninteractive -command %Appdata%\Spotify\cache-spotify.ps1" -set shell = CreateObject("WScript.Shell") -shell.Run command,0, false +command = "powershell.exe -ExecutionPolicy Bypass -nologo -noninteractive -command %Appdata%\Spotify\cache-spotify.ps1" +set shell = CreateObject("WScript.Shell") +shell.Run command,0, false diff --git a/cache-spotify.ps1 b/Cache/cache-spotify.ps1 similarity index 98% rename from cache-spotify.ps1 rename to Cache/cache-spotify.ps1 index 536e944..9cd0c6b 100644 --- a/cache-spotify.ps1 +++ b/Cache/cache-spotify.ps1 @@ -1,13 +1,13 @@ -# Launch Spotify.exe and wait for the process to stop -Start-Process -FilePath $env:APPDATA\Spotify\Spotify.exe; wait-process -name Spotify - -# This block deletes files by the last access time to it, files that have not been changed and have not been opened for more than the number of days you have selected will be deleted. If you need to replace with another number of days, then substitute the value in the 6th row and 118th column (The default is 7 days). -If (Test-Path -Path $env:LOCALAPPDATA\Spotify\Data) { - Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-7) | Remove-Item -} - -# Delete the file mercury.db if its size exceeds 100 MB. -If (Test-Path -Path $env:LOCALAPPDATA\Spotify\mercury.db) { - $file_mercury = Get-Item "$env:LOCALAPPDATA\Spotify\mercury.db" - if ($file_mercury.length -gt 100MB) { Get-ChildItem $env:LOCALAPPDATA\Spotify\mercury.db -File -Recurse | Remove-Item } +# Launch Spotify.exe and wait for the process to stop +Start-Process -FilePath $env:APPDATA\Spotify\Spotify.exe; wait-process -name Spotify + +# This block deletes files by the last access time to it, files that have not been changed and have not been opened for more than the number of days you have selected will be deleted. If you need to replace with another number of days, then substitute the value in the 6th row and 118th column (The default is 7 days). +If (Test-Path -Path $env:LOCALAPPDATA\Spotify\Data) { + Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-7) | Remove-Item +} + +# Delete the file mercury.db if its size exceeds 100 MB. +If (Test-Path -Path $env:LOCALAPPDATA\Spotify\mercury.db) { + $file_mercury = Get-Item "$env:LOCALAPPDATA\Spotify\mercury.db" + if ($file_mercury.length -gt 100MB) { Get-ChildItem $env:LOCALAPPDATA\Spotify\mercury.db -File -Recurse | Remove-Item } } \ No newline at end of file diff --git a/cache_spotify_ru.ps1 b/Cache/cache_spotify_ru.ps1 similarity index 99% rename from cache_spotify_ru.ps1 rename to Cache/cache_spotify_ru.ps1 index 71a349b..a37f832 100644 --- a/cache_spotify_ru.ps1 +++ b/Cache/cache_spotify_ru.ps1 @@ -1,13 +1,13 @@ -# Запускаем Spotify.exe и ждем завершения процесса -Start-Process -FilePath $env:APPDATA\Spotify\Spotify.exe; wait-process -name Spotify - -# Этот блок удаляет файлы кэша по времени последнего доступа к нему, тоесть файлы которые не были изменены и не открывались больше указанного вами количества дней, будут удалены. Если нужно заменить на другое значение подставьте своё значение в 6 строку и 118 столбец (По умолчанию равно 7 дней). -If (Test-Path -Path $env:LOCALAPPDATA\Spotify\Data) { - Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-7) | Remove-Item -} - -# Удаляем файл mercury.db если его размер привышает 100 MB. -If (Test-Path -Path $env:LOCALAPPDATA\Spotify\mercury.db) { - $file_mercury = Get-Item "$env:LOCALAPPDATA\Spotify\mercury.db" - if ($file_mercury.length -gt 100MB) { Get-ChildItem $env:LOCALAPPDATA\Spotify\mercury.db -File -Recurse | Remove-Item } +# Запускаем Spotify.exe и ждем завершения процесса +Start-Process -FilePath $env:APPDATA\Spotify\Spotify.exe; wait-process -name Spotify + +# Этот блок удаляет файлы кэша по времени последнего доступа к нему, тоесть файлы которые не были изменены и не открывались больше указанного вами количества дней, будут удалены. Если нужно заменить на другое значение подставьте своё значение в 6 строку и 118 столбец (По умолчанию равно 7 дней). +If (Test-Path -Path $env:LOCALAPPDATA\Spotify\Data) { + Get-ChildItem $env:LOCALAPPDATA\Spotify\Data -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-7) | Remove-Item +} + +# Удаляем файл mercury.db если его размер привышает 100 MB. +If (Test-Path -Path $env:LOCALAPPDATA\Spotify\mercury.db) { + $file_mercury = Get-Item "$env:LOCALAPPDATA\Spotify\mercury.db" + if ($file_mercury.length -gt 100MB) { Get-ChildItem $env:LOCALAPPDATA\Spotify\mercury.db -File -Recurse | Remove-Item } } \ No newline at end of file diff --git a/Install.ps1 b/Install.ps1 index 7aff877..bf3f0f6 100644 --- a/Install.ps1 +++ b/Install.ps1 @@ -1,5 +1,5 @@ # Ignore errors from `Stop-Process` -$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue' +$PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue # Check Tls12 $tsl_check = [Net.ServicePointManager]::SecurityProtocol @@ -14,9 +14,12 @@ Write-Host "@Amd64fox" -ForegroundColor DarkYellow Write-Host "*****************"`n -$SpotifyDirectory = "$env:APPDATA\Spotify" -$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe" -$Podcasts_off = $false +$spotifyDirectory = "$env:APPDATA\Spotify" +$spotifyExecutable = "$spotifyDirectory\Spotify.exe" +$chrome_elf = "$spotifyDirectory\chrome_elf.dll" +$chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll" +$upgrade_client = $false +$podcasts_off = $false Stop-Process -Name Spotify @@ -36,7 +39,7 @@ $win8 = $win_os -match "\windows 8\b" if ($win11 -or $win10 -or $win8_1 -or $win8) { - # Check and del Windows Store + # Remove Spotify Windows Store If Any if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) { Write-Host 'The Microsoft Store version of Spotify has been detected which is not supported.'`n $ch = Read-Host -Prompt "Uninstall Spotify Windows Store edition (Y/N) " @@ -45,8 +48,7 @@ if ($win11 -or $win10 -or $win8_1 -or $win8) { Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage } else { - Write-Host 'Exiting...'`n - Pause + Read-Host "Exiting...`nPress any key to exit..." exit } } @@ -61,8 +63,8 @@ try { | Set-Location } catch { - Write-Output '' - Pause + Write-Output $_ + Read-Host 'Press any key to exit...' exit } @@ -80,68 +82,147 @@ try { ) } catch { - Write-Output '' + Write-Output $_ + Read-Host "An error occurred while downloading the chrome_elf.zip file`nPress any key to exit..." Start-Sleep } Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD Remove-Item -LiteralPath "$PWD\chrome_elf.zip" -$spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable) -if (-not $spotifyInstalled) { - - try { - $webClient.DownloadFile( - # Remote file URL - 'https://download.scdn.co/SpotifySetup.exe', - # Local file path - "$PWD\SpotifySetup.exe" - ) - } - catch { - Write-Output '' - Pause - exit - } - mkdir $SpotifyDirectory | Out-Null - # Check version Spotify + +try { + $webClient.DownloadFile( + # Remote file URL + 'https://download.scdn.co/SpotifySetup.exe', + # Local file path + "$PWD\SpotifySetup.exe" + ) +} +catch { + Write-Output $_ + Read-Host "An error occurred while downloading the SpotifySetup.exe file`nPress any key to exit..." + exit +} + + + +$spotifyInstalled = (Test-Path -LiteralPath $spotifyExecutable) + +if ($spotifyInstalled) { + + + + # Check last version Spotify online + $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion + $online_version = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' + + + # Check last version Spotify ofline + $ofline_version = (Get-Item $spotifyExecutable).VersionInfo.FileVersion + + + if ($online_version -gt $ofline_version) { + + + do { + $ch = Read-Host -Prompt "Your Spotify $ofline_version version is outdated, it is recommended to upgrade to $online_version `nWant to update ? (Y/N)" + Write-Output $_ + if (!($ch -eq 'n' -or $ch -eq 'y')) { + + Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline + Write-Host "enter again through..." -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host "3" -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host ".2" -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host ".1" + Start-Sleep -Milliseconds 1000 + Clear-Host + } + } + while ($ch -notmatch '^y$|^n$') + if ($ch -eq 'y') { $upgrade_client = $true } + + + } +} + + +# If there is no client or it is outdated, then install + +if (-not $spotifyInstalled -or $upgrade_client) { + $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion $version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' - + Write-Host "Downloading and installing Spotify " -NoNewline Write-Host $version_client -ForegroundColor Green Write-Host "Please wait..."`n - - Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup - - + + # Correcting the error if the spotify installer was launched from the administrator + + [System.Security.Principal.WindowsPrincipal] $principal = [System.Security.Principal.WindowsIdentity]::GetCurrent() + $isUserAdmin = $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) + + + if ($isUserAdmin) { + Write-Host 'Startup detected with administrator rights'`n + $apppath = 'powershell.exe' + $taskname = 'Spotify install' + $action = New-ScheduledTaskAction -Execute $apppath -Argument "-NoLogo -NoProfile -Command & `'$PWD\SpotifySetup.exe`'" + $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) + $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -WakeToRun + Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -Settings $settings -Force | Write-Verbose + Start-ScheduledTask -TaskName $taskname + Start-Sleep -Seconds 2 + Unregister-ScheduledTask -TaskName $taskname -Confirm:$false + Start-Sleep -Seconds 2 + wait-process -name SpotifySetup + } + else { + + Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup + } + + + Stop-Process -Name Spotify Stop-Process -Name SpotifyWebHelper Stop-Process -Name SpotifyFullSetup - $ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки + $ErrorActionPreference = 'SilentlyContinue' # extinguishes light mistakes - # Удалить инсталятор после установки + # Update backup chrome_elf.dll + if (Test-Path -LiteralPath $chrome_elf_bak) { + Remove-item $spotifyDirectory/chrome_elf_bak.dll + Move-Item $chrome_elf $chrome_elf_bak + } + + # Remove spotify installer if (test-path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\") { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force } if (test-path $env:LOCALAPPDATA\Microsoft\Windows\INetCache\) { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\INetCache\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force - + } - + } -if (!(test-path $SpotifyDirectory/chrome_elf_bak.dll)) { - Move-Item $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf_bak.dll + +# Create backup chrome_elf.dll +if (!(Test-Path -LiteralPath $chrome_elf_bak)) { + Move-Item $chrome_elf $chrome_elf_bak } Write-Host 'Patching Spotify...'`n $patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini" -Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory" +Copy-Item -LiteralPath $patchFiles -Destination "$spotifyDirectory" $tempDirectory = $PWD Pop-Location @@ -170,10 +251,10 @@ do { } } while ($ch -notmatch '^y$|^n$') -if ($ch -eq 'y') { $Podcasts_off = $true } +if ($ch -eq 'y') { $podcasts_off = $true } -# Мофифицируем файлы +# Modify files $xpui_spa_patch = "$env:APPDATA\Spotify\Apps\xpui.spa" $xpui_js_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.js" @@ -241,7 +322,7 @@ If (Test-Path $xpui_spa_patch) { If (!($patched_by_spotx -match 'patched by spotx')) { - # Делаем резервную копию xpui.spa если он оригинальный + # Make a backup copy of xpui.spa if it is original $zip.Dispose() Copy-Item $xpui_spa_patch $env:APPDATA\Spotify\Apps\xpui.bak @@ -284,7 +365,7 @@ If (Test-Path $xpui_spa_patch) { -replace '(Enables new playlist creation flow in Web Player and DesktopX",default:)(!1)', '$1!0' # Disable Podcast - if ($Podcasts_off) { + if ($podcasts_off) { $xpuiContents = $xpuiContents ` -replace '"album,playlist,artist,show,station,episode"', '"album,playlist,artist,station"' -replace ',this[.]enableShows=[a-z]', "" } @@ -351,7 +432,7 @@ If (Test-Path $xpui_spa_patch) { } -# Если папки по умолчанию Dekstop не существует, то попытаться найти её через реестр. +# If the default Dekstop folder does not exist, then try to find it through the registry. $ErrorActionPreference = 'SilentlyContinue' if (Test-Path "$env:USERPROFILE\Desktop") { @@ -390,7 +471,7 @@ If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) { # Block updates -$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки +$ErrorActionPreference = 'SilentlyContinue' @@ -422,13 +503,13 @@ while ($ch -notmatch '^y$|^n$|^u$') if ($ch -eq 'y') { - # Если была установка клиента + # If there was a client installation if (!($update_directory)) { - # Создать папку Spotify в Local + # Create Spotify folder in Localappdata New-Item -Path $env:LOCALAPPDATA -Name "Spotify" -ItemType "directory" | Out-Null - #Создать файл Update + # Create Update file New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null $file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update $file.Attributes = "ReadOnly", "System" @@ -447,14 +528,14 @@ if ($ch -eq 'y') { } - # Если клиент уже был + # If the client has already been If ($update_directory) { - #Удалить папку Update если она есть + # Delete the Update folder if it exists if ($Check_folder_file -match '\bDirectory\b') { - #Если у папки Update заблокированы права то разблокировать + # If the rights of the Update folder are blocked, then unblock if ($folder_update_access.AccessToString -match 'Deny') { ($ACL = Get-Acl $env:LOCALAPPDATA\Spotify\Update).access | ForEach-Object { @@ -465,7 +546,7 @@ if ($ch -eq 'y') { Remove-item $env:LOCALAPPDATA\Spotify\Update -Recurse -Force } - #Создать файл Update если его нет + # Create Update file if it doesn't exist if (!($Check_folder_file -match '\bSystem\b' -and $Check_folder_file -match '\bReadOnly\b')) { New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null $file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update @@ -562,10 +643,10 @@ if ($ch -eq 'y') { Start-Sleep -Milliseconds 200 # cache-spotify.ps1 - $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/cache-spotify.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1") + $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Cache/cache-spotify.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1") # Spotify.vbs - $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs") + $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Cache/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs") # Spotify.lnk diff --git a/Install_Rus.bat b/Install_Rus.bat new file mode 100644 index 0000000..e0799ad --- /dev/null +++ b/Install_Rus.bat @@ -0,0 +1,4 @@ +@echo off +powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}"; "& {(Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install_rus.ps1').Content | Invoke-Expression}" +pause +exit \ No newline at end of file diff --git a/Install_rus.ps1 b/Install_rus.ps1 index 6f05f18..6efced0 100644 --- a/Install_rus.ps1 +++ b/Install_rus.ps1 @@ -1,7 +1,7 @@ -# Ignore errors from `Stop-Process` -$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue' +# Игнорировать ошибки из `Stop-Process` +$PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue -# Check Tls12 +# Проверка на наличия сертификата Tls12 $tsl_check = [Net.ServicePointManager]::SecurityProtocol if (!($tsl_check -match '^tls12$' )) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -14,9 +14,12 @@ Write-Host "@Amd64fox" -ForegroundColor DarkYellow Write-Host "*****************"`n -$SpotifyDirectory = "$env:APPDATA\Spotify" -$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe" -$Podcasts_off = $false +$spotifyDirectory = "$env:APPDATA\Spotify" +$spotifyExecutable = "$spotifyDirectory\Spotify.exe" +$chrome_elf = "$spotifyDirectory\chrome_elf.dll" +$chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll" +$upgrade_client = $false +$podcasts_off = $false Stop-Process -Name Spotify @@ -25,7 +28,7 @@ Stop-Process -Name SpotifyWebHelper if ($PSVersionTable.PSVersion.Major -ge 7) { Import-Module Appx -UseWindowsPowerShell } -# Check version Windows +# Проверка версии Windows $win_os = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName $win11 = $win_os -match "\windows 11\b" $win10 = $win_os -match "\windows 10\b" @@ -36,7 +39,7 @@ $win8 = $win_os -match "\windows 8\b" if ($win11 -or $win10 -or $win8_1 -or $win8) { - # Check and del Windows Store + # Удалить Spotify Windows Store если он есть if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) { Write-Host 'Обнаружена версия Spotify из Microsoft Store, которая не поддерживается.'`n $ch = Read-Host -Prompt "Хотите удалить Spotify Microsoft Store ? (Y/N) " @@ -45,8 +48,7 @@ if ($win11 -or $win10 -or $win8_1 -or $win8) { Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage } else { - Write-Host 'Выход...'`n - Pause + Read-Host "Завершение работы...`nНажмите любую клавишу для выхода..." exit } } @@ -61,8 +63,8 @@ try { | Set-Location } catch { - Write-Output '' - Pause + Write-Output $_ + Read-Host 'Нажмите любую клавишу для выхода...' exit } @@ -80,43 +82,114 @@ try { ) } catch { - Write-Output '' + Write-Output $_ + Read-Host "Произошла ошибка во время скачивания файла chrome_elf.zip`nНажмите любую клавишу для выхода..." Start-Sleep } Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD Remove-Item -LiteralPath "$PWD\chrome_elf.zip" -$spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable) -if (-not $spotifyInstalled) { - - try { - $webClient.DownloadFile( - # Remote file URL - 'https://download.scdn.co/SpotifySetup.exe', - # Local file path - "$PWD\SpotifySetup.exe" - ) - } - catch { - Write-Output '' - Pause - exit - } - mkdir $SpotifyDirectory | Out-Null - # Check version Spotify + +try { + $webClient.DownloadFile( + # Remote file URL + 'https://download.scdn.co/SpotifySetup.exe', + # Local file path + "$PWD\SpotifySetup.exe" + ) +} +catch { + Write-Output $_ + Read-Host "Произошла ошибка во время скачивания файла SpotifySetup.exe file`nНажмите любую клавишу для выхода..." + exit +} + + + +$spotifyInstalled = (Test-Path -LiteralPath $spotifyExecutable) + +if ($spotifyInstalled) { + + + + # Проверка последней версии Spotify онлайн + $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion + $online_version = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' + + + # Проверка последней версии Spotify офлайн + $ofline_version = (Get-Item $spotifyExecutable).VersionInfo.FileVersion + + + if ($online_version -gt $ofline_version) { + + + do { + $ch = Read-Host -Prompt "Ваша версия Spotify $ofline_version устарела, рекомендуется обновиться до $online_version `nОбновить ? (Y/N)" + Write-Output $_ + if (!($ch -eq 'n' -or $ch -eq 'y')) { + + Write-Host "Oops, an incorrect value, " -ForegroundColor Red -NoNewline + Write-Host "enter again through..." -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host "3" -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host ".2" -NoNewline + Start-Sleep -Milliseconds 1000 + Write-Host ".1" + Start-Sleep -Milliseconds 1000 + Clear-Host + } + } + while ($ch -notmatch '^y$|^n$') + if ($ch -eq 'y') { $upgrade_client = $true } + + + } +} + + +# Если клиента нет или он устарел, то начинаем установку + +if (-not $spotifyInstalled -or $upgrade_client) { + $version_client_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion $version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' - + Write-Host "Загружаю и устанавливаю Spotify " -NoNewline Write-Host $version_client -ForegroundColor Green Write-Host "Пожалуйста подождите..."`n - Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup - - + # Исправление ошибки, если установщик Spotify был запущен от имени администратора + + [System.Security.Principal.WindowsPrincipal] $principal = [System.Security.Principal.WindowsIdentity]::GetCurrent() + $isUserAdmin = $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) + + + if ($isUserAdmin) { + Write-Host 'Обнаружен запуск с правами администратора'`n + $apppath = 'powershell.exe' + $taskname = 'Spotify install' + $action = New-ScheduledTaskAction -Execute $apppath -Argument "-NoLogo -NoProfile -Command & `'$PWD\SpotifySetup.exe`'" + $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) + $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -WakeToRun + Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -Settings $settings -Force | Write-Verbose + Start-ScheduledTask -TaskName $taskname + Start-Sleep -Seconds 2 + Unregister-ScheduledTask -TaskName $taskname -Confirm:$false + Start-Sleep -Seconds 2 + wait-process -name SpotifySetup + } + else { + + Start-Process -FilePath $PWD\SpotifySetup.exe; wait-process -name SpotifySetup + } + + + Stop-Process -Name Spotify Stop-Process -Name SpotifyWebHelper Stop-Process -Name SpotifyFullSetup @@ -124,24 +197,32 @@ if (-not $spotifyInstalled) { $ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки - # Удалить инсталятор после установки + # Обновить резервную копию chrome_elf.dll + if (Test-Path -LiteralPath $chrome_elf_bak) { + Remove-item $spotifyDirectory/chrome_elf_bak.dll + Move-Item $chrome_elf $chrome_elf_bak + } + + # Удалите установщик Spotify if (test-path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\") { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force } if (test-path $env:LOCALAPPDATA\Microsoft\Windows\INetCache\) { get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\INetCache\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force - + } - + } -if (!(test-path $SpotifyDirectory/chrome_elf_bak.dll)) { - Move-Item $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf_bak.dll + +# Создать резервную копию chrome_elf.dll +if (!(Test-Path -LiteralPath $chrome_elf_bak)) { + Move-Item $chrome_elf $chrome_elf_bak } Write-Host 'Модифицирую Spotify...'`n $patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini" -Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory" +Copy-Item -LiteralPath $patchFiles -Destination "$spotifyDirectory" $tempDirectory = $PWD Pop-Location @@ -170,7 +251,7 @@ do { } } while ($ch -notmatch '^y$|^n$') -if ($ch -eq 'y') { $Podcasts_off = $true } +if ($ch -eq 'y') { $podcasts_off = $true } # Мофифицируем файлы @@ -283,8 +364,8 @@ If (Test-Path $xpui_spa_patch) { <# Enables new playlist creation flow #>` -replace '(Enables new playlist creation flow in Web Player and DesktopX",default:)(!1)', '$1!0' - # Disable Podcast - if ($Podcasts_off) { + # Отключить подкасты + if ($podcasts_off) { $xpuiContents = $xpuiContents ` -replace '"album,playlist,artist,show,station,episode"', '"album,playlist,artist,station"' -replace ',this[.]enableShows=[a-z]', "" } @@ -370,7 +451,7 @@ if (!(Test-Path "$env:USERPROFILE\Desktop")) { -# Shortcut bug +# Испраление бага ярлыка на рабочем столе $ErrorActionPreference = 'SilentlyContinue' If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) { @@ -388,9 +469,9 @@ If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) { -# Block updates +# Блокировка обновлений -$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки +$ErrorActionPreference = 'SilentlyContinue' @@ -562,10 +643,10 @@ if ($ch -eq 'y') { Start-Sleep -Milliseconds 200 # cache-spotify.ps1 - $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/cache_spotify_ru.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1") + $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Cache/cache_spotify_ru.ps1', "$env:APPDATA\Spotify\cache-spotify.ps1") # Spotify.vbs - $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs") + $webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Cache/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs") # Spotify.lnk