-
Notifications
You must be signed in to change notification settings - Fork 373
/
ChocolateyInstall.ps1
33 lines (29 loc) · 1.22 KB
/
ChocolateyInstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$downloadDir = Get-PackageCacheLocation
$installer = 'SpotifyFullSetup.exe'
$arguments = @{
packageName = $env:ChocolateyPackageName
softwareName = 'Spotify'
file = Join-Path $downloadDir $installer
url = 'https://download.spotify.com/SpotifyFullSetup.exe'
checksum = 'D5F5B8B33190F7DE0B71D09F2E45C4B09B5BEBE173FD5AACA10C452BB817D65889D6919C0B57FC7E55A021D5B274F2BCB0B8B4AB382DE097995CEEBB16DC589F'
fileType = 'exe'
checksumType = 'sha512'
silentArgs = '/silent'
validExitCodes = @(0, 1641, 3010)
}
# Download the installer
$arguments['file'] = Get-ChocolateyWebFile @arguments
# It doesn't matter what time we choose, we need to start it manually
schtasks.exe /Create /SC Once /st (Get-Date -Format 'HH:mm') /TN $arguments['packageName'] /TR "'$($arguments['file'])' $($arguments['silentArgs'])" /F 2>$null
schtasks.exe /Run /TN $arguments['packageName']
Start-Sleep -s 1
schtasks.exe /Delete /TN $arguments['packageName'] /F
# Wait for Spotify to start, then kill it
$done = $false
do {
if (Get-Process Spotify -ErrorAction SilentlyContinue) {
Stop-Process -name Spotify
$done = $true
}
Start-Sleep -s 10
} until ($done)