3
3
;;;== =,,,PowerShell.exe -ExecutionPolicy Bypass -Command " & '%~dp0 ps.ps1'"
4
4
;;;== =,,,del /s /q " %~dp0 ps.ps1" > NUL 2 >& 1
5
5
;;;== =,,,pause
6
-
7
6
# Ignore errors from `Stop-Process`
8
7
$PSDefaultParameterValues['Stop-Process:ErrorAction'] = 'SilentlyContinue'
9
8
@@ -16,8 +15,7 @@ Author: @rednek46
16
15
$SpotifyDirectory = " $env:APPDATA\Spotify"
17
16
$SpotifyExecutable = " $SpotifyDirectory\Spotify.exe"
18
17
19
- Write-Host 'Terminating Spotify...'
20
- Write-Host(" " )
18
+ Write-Host 'Stopping Spotify...'
21
19
Stop-Process -Name Spotify
22
20
Stop-Process -Name SpotifyWebHelper
23
21
@@ -32,58 +30,80 @@ To uninstall, search for Spotify in the start menu and right-click on the result
32
30
exit
33
31
}
34
32
35
- mkdir $env:TEMP/BlockTheSpotTEMP `
33
+
34
+ Push-Location -LiteralPath $env:TEMP
35
+ try {
36
+ # Unique directory name based on time
37
+ New-Item -Type Directory -Name " BlockTheSpot-$(Get-Date -UFormat '%Y-% m-%d_% H-%M-% S')" `
36
38
| Convert-Path `
37
39
| Set-Location
40
+ } catch {
41
+ Write-Output $_
42
+ Pause
43
+ exit
44
+ }
38
45
39
- Write-Host(" Downloading latest patch (chrome_elf.zip)" )
40
- Write-Host(" " )
41
-
46
+ Write-Host 'Downloading latest patch (chrome_elf.zip)...'`n
42
47
$webClient = New-Object -TypeName System.Net.WebClient
43
48
try {
44
49
$webClient.DownloadFile(
50
+ # Remote file URL
45
51
'https://github.com/mrpond/BlockTheSpot/releases/latest/download/chrome_elf.zip',
52
+ # Local file path
46
53
" $PWD\chrome_elf.zip"
47
54
)
48
55
} catch {
49
56
Write-Output $_
50
57
Sleep
51
58
}
59
+ Expand-Archive -Force -LiteralPath " $PWD\chrome_elf.zip" -DestinationPath $PWD
60
+ Remove-Item -LiteralPath " $PWD\chrome_elf.zip"
52
61
53
- if (test-path $SpotifyDirectory/Spotify.exe){
54
-
55
- if (!(test-path $SpotifyDirectory/chrome_elf.dll.bak)){
56
-
57
- move $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak > $null 2 >& 1
58
- }
59
-
60
- } else {
61
- write-host @ '
62
- Spotify installation was not detected. Downloading Latest Spotify full setup.
63
- Please wait..
62
+ $spotifyInstalled = (Test-Path -LiteralPath $SpotifyExecutable)
63
+ if (-not $spotifyInstalled) {
64
+ Write-Host @ '
65
+ Spotify installation was not detected.
66
+ Downloading Latest Spotify full setup, please wait...
64
67
'@
65
- try {
68
+ try {
66
69
$webClient.DownloadFile(
70
+ # Remote file URL
67
71
'https://download.scdn.co/SpotifyFullSetup.exe',
72
+ # Local file path
68
73
" $PWD\SpotifyFullSetup.exe"
69
74
)
70
- } catch {
71
- Write-Output $_
72
- Sleep
73
- }
74
-
75
- write-host(" Running installation..." )
76
-
77
- .\SpotifyFullSetup.exe | Out-Null
75
+ } catch {
76
+ Write-Output $_
77
+ Pause
78
+ exit
79
+ }
80
+ mkdir $SpotifyDirectory > $null 2 >& 1
81
+ Write-Host 'Running installation...'
82
+ Start-Process -FilePath " $PWD\SpotifyFullSetup.exe"
83
+ Write-Host 'Stopping Spotify...Again'
84
+ while ((Get-Process -name Spotify -ErrorAction SilentlyContinue) -eq $null){
85
+ #waiting until installation complete
86
+ }
87
+ Stop-Process -Name Spotify > $null 2 >& 1
88
+ Stop-Process -Name SpotifyWebHelper > $null 2 >& 1
89
+ Stop-Process -Name SpotifyFullSetup > $null 2 >& 1
90
+ }
78
91
79
- rm $pwd/SpotifyFullSetup.exe > $null 2 >& 1
80
- move $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak > $null 2 >& 1
92
+ if (!(test-path $SpotifyDirectory/chrome_elf.dll.bak)){
93
+ move $SpotifyDirectory\chrome_elf.dll $SpotifyDirectory\chrome_elf.dll.bak > $null 2 >& 1
81
94
}
82
- Write-Host( " Patching Spotify.. " )
83
- Expand-Archive -Force 'chrome_elf.zip' $pwd
95
+
96
+ Write-Host 'Patching Spotify...'
84
97
$patchFiles = " $PWD\chrome_elf.dll" , " $PWD\config.ini"
85
98
Copy-Item -LiteralPath $patchFiles -Destination " $SpotifyDirectory"
86
- cd $env:HOMEPATH
87
- rm -Recurse $env:TEMP\BlockTheSpotTEMP
88
- Write-Host(" Patching Completed." )
89
- exit
99
+
100
+ $tempDirectory = $PWD
101
+ Pop-Location
102
+
103
+ Remove-Item -Recurse -LiteralPath $tempDirectory
104
+
105
+ Write-Host 'Patching Complete, starting Spotify...'
106
+ Start-Process -WorkingDirectory $SpotifyDirectory -FilePath $SpotifyExecutable
107
+ Write-Host 'Done.'
108
+ pause
109
+ exit
0 commit comments