mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-04-23 19:40:19 +10:00
new fix if there was a launch from the admin
Found an easier fix to fix a bug installing Spotify with administrator rights
This commit is contained in:
33
Install.ps1
33
Install.ps1
@@ -14,7 +14,6 @@ $chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll"
|
|||||||
$upgrade_client = $false
|
$upgrade_client = $false
|
||||||
$podcasts_off = $false
|
$podcasts_off = $false
|
||||||
$spotx_new = $false
|
$spotx_new = $false
|
||||||
$run_as_admin = $false
|
|
||||||
$block_update = $false
|
$block_update = $false
|
||||||
$cache_install = $false
|
$cache_install = $false
|
||||||
|
|
||||||
@@ -25,16 +24,6 @@ if (!($tsl_check -match '^tls12$' )) {
|
|||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checking startup rights
|
|
||||||
[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
|
|
||||||
$run_as_admin = $true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Stop-Process -Name Spotify
|
Stop-Process -Name Spotify
|
||||||
Stop-Process -Name SpotifyWebHelper
|
Stop-Process -Name SpotifyWebHelper
|
||||||
|
|
||||||
@@ -216,24 +205,10 @@ if (-not $spotifyInstalled -or $upgrade_client) {
|
|||||||
Remove-Item $spotifyDirectory -Include *chrome_elf* -Recurse -Force
|
Remove-Item $spotifyDirectory -Include *chrome_elf* -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# Correcting the error if the spotify installer was launched from the administrator
|
# Client installation
|
||||||
|
Start-Process -FilePath explorer.exe -ArgumentList $PWD\SpotifySetup.exe
|
||||||
if ($run_as_admin) {
|
while (-not (get-process | Where-Object { $_.ProcessName -eq 'SpotifySetup' })) {}
|
||||||
$apppath = 'powershell.exe'
|
wait-process -name SpotifySetup
|
||||||
$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 Spotify
|
||||||
Stop-Process -Name SpotifyWebHelper
|
Stop-Process -Name SpotifyWebHelper
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ $chrome_elf_bak = "$spotifyDirectory\chrome_elf_bak.dll"
|
|||||||
$upgrade_client = $false
|
$upgrade_client = $false
|
||||||
$podcasts_off = $false
|
$podcasts_off = $false
|
||||||
$spotx_new = $false
|
$spotx_new = $false
|
||||||
$run_as_admin = $false
|
|
||||||
$block_update = $false
|
$block_update = $false
|
||||||
$cache_install = $false
|
$cache_install = $false
|
||||||
|
|
||||||
@@ -25,16 +24,6 @@ if (!($tsl_check -match '^tls12$' )) {
|
|||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
}
|
}
|
||||||
|
|
||||||
# Проверка прав запуска
|
|
||||||
[System.Security.Principal.WindowsPrincipal] $principal = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
|
||||||
$isUserAdmin = $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
||||||
|
|
||||||
if ($isUserAdmin) {
|
|
||||||
Write-Host 'Обнаружен запуск с правами администратора'`n
|
|
||||||
$run_as_admin = $true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Stop-Process -Name Spotify
|
Stop-Process -Name Spotify
|
||||||
Stop-Process -Name SpotifyWebHelper
|
Stop-Process -Name SpotifyWebHelper
|
||||||
|
|
||||||
@@ -215,26 +204,12 @@ if (-not $spotifyInstalled -or $upgrade_client) {
|
|||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 1
|
||||||
Remove-Item $spotifyDirectory -Include *chrome_elf* -Recurse -Force
|
Remove-Item $spotifyDirectory -Include *chrome_elf* -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
# Исправление ошибки, если установщик Spotify был запущен от администратора
|
# Установка клиента
|
||||||
|
Start-Process -FilePath explorer.exe -ArgumentList $PWD\SpotifySetup.exe
|
||||||
if ($run_as_admin) {
|
while (-not (get-process | Where-Object { $_.ProcessName -eq 'SpotifySetup' })) {}
|
||||||
$apppath = 'powershell.exe'
|
wait-process -name SpotifySetup
|
||||||
$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 Spotify
|
||||||
Stop-Process -Name SpotifyWebHelper
|
Stop-Process -Name SpotifyWebHelper
|
||||||
Stop-Process -Name SpotifyFullSetup
|
Stop-Process -Name SpotifyFullSetup
|
||||||
|
|||||||
Reference in New Issue
Block a user