mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-06-20 06:10:05 +10:00
Client update, error starting with administrator rights, code and file optimization
- Added the ability to update the Spotify client if a newer version is found for your region - Fixed error if the script was run with administrator rights - Fixed error when updating backup copy of chrome_elf_bak.dll - Fixed bug with chrome_elf_bak.dll - Optimization of code and files
This commit is contained in:
+130
-49
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user