Update Install.ps1

- Added a rule if the "desktop" folder was not found
- added possible answer options
This commit is contained in:
amd64fox
2021-08-22 05:11:33 +03:00
committed by GitHub
parent dd8acaaa59
commit 8c950efbf0
+55 -14
View File
@@ -199,12 +199,18 @@ If (!($file_css -match 'patched by spotx')) {
Rename-Item -path $env:APPDATA\Spotify\Apps\xpui.zip -NewName $env:APPDATA\Spotify\Apps\xpui.spa
Remove-item $env:APPDATA\Spotify\Apps\temporary -Recurse
# Shortcut bug
$ErrorActionPreference = 'SilentlyContinue'
If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
$source = "$env:APPDATA\Spotify\Spotify.exe"
$target = "$env:USERPROFILE\Desktop\Spotify.lnk"
$WorkingDir = "$env:APPDATA\Spotify"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($target)
$Shortcut.WorkingDirectory = $WorkingDir
$Shortcut.TargetPath = $source
$Shortcut.Save()
}
@@ -212,6 +218,7 @@ If (!(Test-Path $env:USERPROFILE\Desktop\Spotify.lnk)) {
# Block updates
$ErrorActionPreference = 'SilentlyContinue' # Команда гасит легкие ошибки
@@ -297,6 +304,8 @@ if ($ch -eq 'n') {
if ($ch -eq 'u') {
If ($migrator_bak -and $Check_folder_file -match '\bSystem\b' -and $Check_folder_file -match '\bReadOnly\b') {
If ($update_directory_file) {
Remove-item $env:LOCALAPPDATA\Spotify\Update -Recurse -Force
@@ -308,8 +317,12 @@ if ($ch -eq 'u') {
Rename-Item -path $env:APPDATA\Spotify\SpotifyMigrator.bak -NewName $env:APPDATA\Spotify\SpotifyMigrator.exe
}
Write-Host "Updates unlocked" -ForegroundColor Green
}
If (!($migrator_bak -and $Check_folder_file -match '\bSystem\b' -and $Check_folder_file -match '\bReadOnly\b')) {
Write-Host "Oops, updates are not blocked"
}
}
@@ -329,6 +342,12 @@ if ($ch -eq 'y') {
$test_cache_spotify_ps = Test-Path -Path $env:APPDATA\Spotify\cache-spotify.ps1
$test_spotify_vbs = Test-Path -Path $env:APPDATA\Spotify\Spotify.vbs
$desktop_folder = Get-ItemProperty -Path $env:USERPROFILE\Desktop | SELECT Attributes
# Если папки по умолчанию Dekstop не существует, то установку кэша отменить.
if ($desktop_folder -match '\bDirectory\b') {
If ($test_cache_spotify_ps) {
@@ -346,14 +365,22 @@ if ($ch -eq 'y') {
# Spotify.vbs
$webClient.DownloadFile('https://raw.githubusercontent.com/amd64fox/SpotX/main/Spotify.vbs', "$env:APPDATA\Spotify\Spotify.vbs")
# Spotify.lnk
$source = "$env:APPDATA\Spotify\Spotify.vbs"
$target = "$env:USERPROFILE\Desktop\Spotify.lnk"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($target)
$Shortcut.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
$Shortcut.TargetPath = $source
$Shortcut.Save()
$source2 = "$env:APPDATA\Spotify\Spotify.vbs"
$target2 = "$env:USERPROFILE\Desktop\Spotify.lnk"
$WorkingDir2 = "$env:APPDATA\Spotify"
$WshShell2 = New-Object -comObject WScript.Shell
$Shortcut2 = $WshShell2.CreateShortcut($target2)
$Shortcut2.WorkingDirectory = $WorkingDir2
$Shortcut2.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
$Shortcut2.TargetPath = $source2
$Shortcut2.Save()
$ch = Read-Host -Prompt "Cache files that have not been used for more than XX days will be deleted.
Enter the number of days from 1 to 100"
@@ -392,7 +419,13 @@ if ($ch -eq 'y') {
}
}
else {
Write-Host "Error, i can't find the 'Desktop' folder" -ForegroundColor Red
Write-Host "Installation completed" -ForegroundColor Green
Exit
}
}
if ($ch -eq 'n') {
@@ -410,17 +443,25 @@ if ($ch -eq 'u') {
Remove-item $env:APPDATA\Spotify\cache-spotify.ps1 -Recurse -Force
Remove-item $env:APPDATA\Spotify\Spotify.vbs -Recurse -Force
$source = "$env:APPDATA\Spotify\Spotify.exe"
$target = "$env:USERPROFILE\Desktop\Spotify.lnk"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($target)
$Shortcut.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
$Shortcut.TargetPath = $source
$Shortcut.Save()
$source3 = "$env:APPDATA\Spotify\Spotify.exe"
$target3 = "$env:USERPROFILE\Desktop\Spotify.lnk"
$WorkingDir3 = "$env:APPDATA\Spotify"
$WshShell3 = New-Object -comObject WScript.Shell
$Shortcut3 = $WshShell3.CreateShortcut($target3)
$Shortcut3.WorkingDirectory = $WorkingDir3
$Shortcut3.IconLocation = "$env:APPDATA\Spotify\Spotify.exe"
$Shortcut3.TargetPath = $source3
$Shortcut3.Save()
Write-Host "Cache cleanup script removed" -ForegroundColor Green
Write-Host "Installation completed" -ForegroundColor Green
exit
}
If (!($test_cache_spotify_ps -and $test_spotify_vbs)) {
Write-Host "Oops, no cache clearing script found"
Write-Host "Installation completed" -ForegroundColor Green