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:
amd64fox
2022-01-07 15:34:22 +03:00
parent f4185b2364
commit deae6dd38b
6 changed files with 297 additions and 131 deletions
View File
+129 -48
View File
@@ -1,5 +1,5 @@
# Ignore errors from `Stop-Process` # Ignore errors from `Stop-Process`
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue' $PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue
# Check Tls12 # Check Tls12
$tsl_check = [Net.ServicePointManager]::SecurityProtocol $tsl_check = [Net.ServicePointManager]::SecurityProtocol
@@ -14,9 +14,12 @@ Write-Host "@Amd64fox" -ForegroundColor DarkYellow
Write-Host "*****************"`n Write-Host "*****************"`n
$SpotifyDirectory = "$env:APPDATA\Spotify" $spotifyDirectory = "$env:APPDATA\Spotify"
$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe" $spotifyExecutable = "$spotifyDirectory\Spotify.exe"
$Podcasts_off = $false $chrome_elf = "$spotifyDirectory\chrome_elf.dll"
$chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll"
$upgrade_client = $false
$podcasts_off = $false
Stop-Process -Name Spotify Stop-Process -Name Spotify
@@ -36,7 +39,7 @@ $win8 = $win_os -match "\windows 8\b"
if ($win11 -or $win10 -or $win8_1 -or $win8) { 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) { if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) {
Write-Host 'The Microsoft Store version of Spotify has been detected which is not supported.'`n 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) " $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 Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage
} }
else { else {
Write-Host 'Exiting...'`n Read-Host "Exiting...`nPress any key to exit..."
Pause
exit exit
} }
} }
@@ -61,8 +63,8 @@ try {
| Set-Location | Set-Location
} }
catch { catch {
Write-Output '' Write-Output $_
Pause Read-Host 'Press any key to exit...'
exit exit
} }
@@ -80,32 +82,79 @@ try {
) )
} }
catch { catch {
Write-Output '' Write-Output $_
Read-Host "An error occurred while downloading the chrome_elf.zip file`nPress any key to exit..."
Start-Sleep Start-Sleep
} }
Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD
Remove-Item -LiteralPath "$PWD\chrome_elf.zip" 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_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion
$version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' $version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w'
@@ -113,7 +162,31 @@ if (-not $spotifyInstalled) {
Write-Host $version_client -ForegroundColor Green Write-Host $version_client -ForegroundColor Green
Write-Host "Please wait..."`n 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
}
@@ -122,9 +195,15 @@ if (-not $spotifyInstalled) {
Stop-Process -Name SpotifyFullSetup 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\") { 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 get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force
} }
@@ -135,13 +214,15 @@ if (-not $spotifyInstalled) {
} }
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 Write-Host 'Patching Spotify...'`n
$patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini" $patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini"
Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory" Copy-Item -LiteralPath $patchFiles -Destination "$spotifyDirectory"
$tempDirectory = $PWD $tempDirectory = $PWD
Pop-Location Pop-Location
@@ -170,10 +251,10 @@ do {
} }
} }
while ($ch -notmatch '^y$|^n$') 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_spa_patch = "$env:APPDATA\Spotify\Apps\xpui.spa"
$xpui_js_patch = "$env:APPDATA\Spotify\Apps\xpui\xpui.js" $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')) { If (!($patched_by_spotx -match 'patched by spotx')) {
# Делаем резервную копию xpui.spa если он оригинальный # Make a backup copy of xpui.spa if it is original
$zip.Dispose() $zip.Dispose()
Copy-Item $xpui_spa_patch $env:APPDATA\Spotify\Apps\xpui.bak 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' -replace '(Enables new playlist creation flow in Web Player and DesktopX",default:)(!1)', '$1!0'
# Disable Podcast # Disable Podcast
if ($Podcasts_off) { if ($podcasts_off) {
$xpuiContents = $xpuiContents ` $xpuiContents = $xpuiContents `
-replace '"album,playlist,artist,show,station,episode"', '"album,playlist,artist,station"' -replace ',this[.]enableShows=[a-z]', "" -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' $ErrorActionPreference = 'SilentlyContinue'
if (Test-Path "$env:USERPROFILE\Desktop") { if (Test-Path "$env:USERPROFILE\Desktop") {
@@ -390,7 +471,7 @@ If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
# Block updates # Block updates
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки $ErrorActionPreference = 'SilentlyContinue'
@@ -422,13 +503,13 @@ while ($ch -notmatch '^y$|^n$|^u$')
if ($ch -eq 'y') { if ($ch -eq 'y') {
# Если была установка клиента # If there was a client installation
if (!($update_directory)) { if (!($update_directory)) {
# Создать папку Spotify в Local # Create Spotify folder in Localappdata
New-Item -Path $env:LOCALAPPDATA -Name "Spotify" -ItemType "directory" | Out-Null 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 New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update $file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
$file.Attributes = "ReadOnly", "System" $file.Attributes = "ReadOnly", "System"
@@ -447,14 +528,14 @@ if ($ch -eq 'y') {
} }
# Если клиент уже был # If the client has already been
If ($update_directory) { If ($update_directory) {
#Удалить папку Update если она есть # Delete the Update folder if it exists
if ($Check_folder_file -match '\bDirectory\b') { 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') { if ($folder_update_access.AccessToString -match 'Deny') {
($ACL = Get-Acl $env:LOCALAPPDATA\Spotify\Update).access | ForEach-Object { ($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 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')) { 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 New-Item -Path $env:LOCALAPPDATA\Spotify\ -Name "Update" -ItemType "file" -Value "STOPIT" | Out-Null
$file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update $file = Get-ItemProperty -Path $env:LOCALAPPDATA\Spotify\Update
@@ -562,10 +643,10 @@ if ($ch -eq 'y') {
Start-Sleep -Milliseconds 200 Start-Sleep -Milliseconds 200
# cache-spotify.ps1 # 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 # 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 # Spotify.lnk
+4
View File
@@ -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
+124 -43
View File
@@ -1,7 +1,7 @@
# Ignore errors from `Stop-Process` # Игнорировать ошибки из `Stop-Process`
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue' $PSDefaultParameterValues['Stop-Process:ErrorAction'] = [System.Management.Automation.ActionPreference]::SilentlyContinue
# Check Tls12 # Проверка на наличия сертификата Tls12
$tsl_check = [Net.ServicePointManager]::SecurityProtocol $tsl_check = [Net.ServicePointManager]::SecurityProtocol
if (!($tsl_check -match '^tls12$' )) { if (!($tsl_check -match '^tls12$' )) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@@ -14,9 +14,12 @@ Write-Host "@Amd64fox" -ForegroundColor DarkYellow
Write-Host "*****************"`n Write-Host "*****************"`n
$SpotifyDirectory = "$env:APPDATA\Spotify" $spotifyDirectory = "$env:APPDATA\Spotify"
$SpotifyExecutable = "$SpotifyDirectory\Spotify.exe" $spotifyExecutable = "$spotifyDirectory\Spotify.exe"
$Podcasts_off = $false $chrome_elf = "$spotifyDirectory\chrome_elf.dll"
$chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll"
$upgrade_client = $false
$podcasts_off = $false
Stop-Process -Name Spotify Stop-Process -Name Spotify
@@ -25,7 +28,7 @@ Stop-Process -Name SpotifyWebHelper
if ($PSVersionTable.PSVersion.Major -ge 7) { if ($PSVersionTable.PSVersion.Major -ge 7) {
Import-Module Appx -UseWindowsPowerShell Import-Module Appx -UseWindowsPowerShell
} }
# Check version Windows # Проверка версии Windows
$win_os = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName $win_os = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName
$win11 = $win_os -match "\windows 11\b" $win11 = $win_os -match "\windows 11\b"
$win10 = $win_os -match "\windows 10\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) { if ($win11 -or $win10 -or $win8_1 -or $win8) {
# Check and del Windows Store # Удалить Spotify Windows Store если он есть
if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) { if (Get-AppxPackage -Name SpotifyAB.SpotifyMusic) {
Write-Host 'Обнаружена версия Spotify из Microsoft Store, которая не поддерживается.'`n Write-Host 'Обнаружена версия Spotify из Microsoft Store, которая не поддерживается.'`n
$ch = Read-Host -Prompt "Хотите удалить Spotify Microsoft Store ? (Y/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 Get-AppxPackage -Name SpotifyAB.SpotifyMusic | Remove-AppxPackage
} }
else { else {
Write-Host 'Выход...'`n Read-Host "Завершение работы...`nНажмите любую клавишу для выхода..."
Pause
exit exit
} }
} }
@@ -61,8 +63,8 @@ try {
| Set-Location | Set-Location
} }
catch { catch {
Write-Output '' Write-Output $_
Pause Read-Host 'Нажмите любую клавишу для выхода...'
exit exit
} }
@@ -80,32 +82,79 @@ try {
) )
} }
catch { catch {
Write-Output '' Write-Output $_
Read-Host "Произошла ошибка во время скачивания файла chrome_elf.zip`nНажмите любую клавишу для выхода..."
Start-Sleep Start-Sleep
} }
Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD Expand-Archive -Force -LiteralPath "$PWD\chrome_elf.zip" -DestinationPath $PWD
Remove-Item -LiteralPath "$PWD\chrome_elf.zip" 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_check = (get-item $PWD\SpotifySetup.exe).VersionInfo.ProductVersion
$version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w' $version_client = $version_client_check -split '.\w\w\w\w\w\w\w\w\w'
@@ -113,7 +162,31 @@ if (-not $spotifyInstalled) {
Write-Host $version_client -ForegroundColor Green Write-Host $version_client -ForegroundColor Green
Write-Host "Пожалуйста подождите..."`n 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
}
@@ -124,7 +197,13 @@ if (-not $spotifyInstalled) {
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки $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\") { 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 get-childitem -path "$env:LOCALAPPDATA\Microsoft\Windows\Temporary Internet Files\" -Recurse -Force -Filter "SpotifyFullSetup*" | remove-item -Force
} }
@@ -135,13 +214,15 @@ if (-not $spotifyInstalled) {
} }
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 Write-Host 'Модифицирую Spotify...'`n
$patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini" $patchFiles = "$PWD\chrome_elf.dll", "$PWD\config.ini"
Copy-Item -LiteralPath $patchFiles -Destination "$SpotifyDirectory" Copy-Item -LiteralPath $patchFiles -Destination "$spotifyDirectory"
$tempDirectory = $PWD $tempDirectory = $PWD
Pop-Location Pop-Location
@@ -170,7 +251,7 @@ do {
} }
} }
while ($ch -notmatch '^y$|^n$') 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 #>` <# Enables new playlist creation flow #>`
-replace '(Enables new playlist creation flow in Web Player and DesktopX",default:)(!1)', '$1!0' -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 ` $xpuiContents = $xpuiContents `
-replace '"album,playlist,artist,show,station,episode"', '"album,playlist,artist,station"' -replace ',this[.]enableShows=[a-z]', "" -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' $ErrorActionPreference = 'SilentlyContinue'
If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) { 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 Start-Sleep -Milliseconds 200
# cache-spotify.ps1 # 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 # 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 # Spotify.lnk