Index: dev/install_python_gtk.ps1 ================================================================== --- dev/install_python_gtk.ps1 +++ dev/install_python_gtk.ps1 @@ -71,11 +71,11 @@ "Python requests", "requests", # no download url, pip handles this "easy_install", "", "", - "{PYTHON}\Lib\site-packages\requests-2.12.1-py2.7.egg", + "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg", "", '' ), @( "LXML 2.3", @@ -181,15 +181,16 @@ ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– "@ } function Ask-First { Write-Host "" - if ((Ask "Do you want to install Python and Gtk now? [Y/n] ") -notmatch "^[yY]|^$") { + if ((Ask "Do you want install Streamtuner2 and its Python dependencies now? [Y/n] ") -notmatch "^[yY]|^$") { $tasks = $tasks[7..($tasks.length-1)] - return + exit } - $reuseCachedFiles = (Ask "Reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]" +# $reuseCachedFiles = (Ask "Reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]" + $reuseCachedFiles = (Ask "Reuse any cached setup files or ignore them? [r/I] ") -match "^[Rr]" $optionalInstall = (Ask "Install optional components? [y/N] ") -match "^[Yy]" Write-Host "" return $reuseCachedFiles, $optionalInstall } @@ -211,11 +212,11 @@ #-- create Desktop/Startmenu shortcuts function Make-Shortcut { [CmdletBinding()] param($dir, $name, $target, $arg=$false) if (!(Test-Path -Path $dir)) { - New-Item -Path $dir -ItemType directory 2> $null + New-Item -Path $dir -ItemType directory > $null } $wsh = New-Object -ComObject WScript.Shell if (!$wsh) { return } $lnk = $wsh.CreateShortcut("$dir\$name") $lnk.TargetPath = $target @@ -230,24 +231,21 @@ #-- create uninstall script and registry key function Create-Uninstallscript { [CmdletBinding()] param() #Write-Host " → Creating uninstall script" - $UninstallScriptPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd" $installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\')) - $UninstallScript = Get-Content -Path $UninstallScriptPath - Out-File -FilePath $UninstallScriptPath -Encoding ascii -InputObject "@set installFolder=$installFolder" - Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set usrFolder=$usrFolder" - Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set Python=$PYTHON" - Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@set StreamripperFolder=$STREAMRIPPER" - Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject "@echo off" + $UninstallScript = Get-Content -Path $UninstallPath + Out-File -FilePath $UninstallPath -Encoding ascii -InputObject @" +@set installFolder=$installFolder +@set usrFolder=$usrFolder +@set Python=$PYTHON +@set StreamripperFolder=$STREAMRIPPER +"@ for ($i=4; $i -lt $UninstallScript.Length ; $i++) { - Out-File -FilePath $UninstallScriptPath -Encoding ascii -Append -InputObject $UninstallScript[$i] + Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $UninstallScript[$i] } - #Out-File -FilePath "$UsrFolder\share\streamtuner2\dev\Y" -Encoding ascii -InputObject "Y" - #if (Test-IsElevated) { - #Write-Host " Writing to registry" Remove-Item -Path $regPathCU\Streamtuner2 2> $null New-Item $regPathCU -Name "Streamtuner2" > $null Set-Location -Path $regPathCU\Streamtuner2 New-ItemProperty -Path . -Name DisplayName -PropertyType String -Value "Streamtuner2" > $null New-ItemProperty -Path . -Name DisplayVersion -PropertyType String -Value "2.2.0" > $null @@ -271,11 +269,11 @@ #-- colorized Read-Host function Ask($str) { if ($str -cmatch "^(.+?)(\[[a-z/]*)([A-Z]+)([\w/]*\])(.*)$") { Write-Host -n -f Yellow $matches[1] # Want to install Write-Host -n -f Gray $matches[2] # [n/ - Write-Host -n -f DarkCyan $matches[3] # Y + Write-Host -n -f Green $matches[3] # Y Write-Host -n -f Gray $matches[4] # /a] Write-Host -n -f Yellow $matches[5] # ? } else { Write-Host -n -f Yellow $str @@ -339,19 +337,19 @@ $checkpath = $checkpath -replace "{PYTHON}","$PYTHON" if (($is_optional -and !$optionalInstall) -or (!$regkey -and !$checkpath)) { continue } if ($presearch) { # expression for e.g. registry → path lookup - Invoke-Expression $presearch # should set $_found + global $PLACEHOLDER variable + Invoke-Expression $presearch > $null # should set $_found + global $PLACEHOLDER variable } elseif ($checkpath) { if (Test-Path $checkpath) { $_found = $checkpath } } elseif ($regkey -and (Test-Path $regkey)) { - $_found = $regkey -replace ".+\\", "" + $_found = "installer/registry" } if (!$_found) { Write-Host " - $title not found" $result = 0; } @@ -377,10 +375,11 @@ #-- ask before running Clear-Host +$host.ui.RawUI.BackgroundColor = ($bckgrnd = 'Black') Console-MaxHeight Display-Logo Check-Package $PYTHON = Check-PythonInstall $reuseCachedFiles, $optionalInstall = Ask-First @@ -402,11 +401,11 @@ Write-Host -b DarkBlue "`n $title `n" chdir($TEMP); # test if element (file path or registry key) already exists: if ($testpath -AND ($reinstall -ne "all") -AND (Test-Path -Path $testpath)) { - Write-Host -f Green -NoNewline " → Is already present." + Write-Host -f DarkGreen -NoNewline " → Is already present." if ($reinstall -eq "none") { continue tasks } Switch -regex ( Ask " Reinstall [y/N/all/none]? " ) { "^all|always|re|^A" { $reinstall = "all"; break } "never|none|skip|^S" { $reinstall = "none"; continue tasks } "^y|yes|1|go|^R" { break } # YES @@ -436,24 +435,24 @@ } else { $cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #" } } - Write-Host -f DarkYellow " → $cmd" + Write-Host -f DarkGray " → $cmd" Invoke-Expression "$cmd" } # msi elseif ($file -match ".+.msi$") { - Write-Host -f DarkYellow (" → msiexec /i " + "$file " + $args) + Write-Host -f DarkGray (" → msiexec /i " + "$file " + $args) Start-Process -Wait msiexec -ArgumentList /i,"$TEMP\$file", $args if ($regkey) { Set-ItemProperty -Path "$regkey" -Name "WindowsInstaller" -Value "0" } } # exe elseif ($file -match ".+.exe$") { - write-host -f DarkYellow " → $file $args" + write-host -f DarkGray " → $file $args" if ($args) { Start-Process -Wait "$TEMP\$file" -ArgumentList $args } else { Start-Process -Wait "$TEMP\$file" Index: dev/uninstall.cmd ================================================================== --- dev/uninstall.cmd +++ dev/uninstall.cmd @@ -1,8 +1,9 @@ @set installFolder=Do_not_change @set usrFolder=Do_not_change @set Python=Do_not_change +@set StreamripperFolder=Do_not_change @echo off >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( @@ -18,15 +19,11 @@ exit /B :goADMIN pushd "%CD%" CD /D "%~dp0" - - - cls - echo ----------------------------------------------------------------------------- echo ^| ^| echo ^| _____/\\\\\\\\\\\____/\\\\\\\\\\\\\\\____/\\\\\\\\\_____ ^| echo ^| ___/\\\/////////\\\_\///////\\\/////___/\\\///////\\\___ ^| echo ^| __\//\\\______\///________\/\\\_______\///______\//\\\__ ^| @@ -46,44 +43,62 @@ setlocal enableextensions cd /d "%~dp0" if NOT "%cd%" == "%TEMP%" ( - copy "%UsrFolder%\share\streamtuner2\dev\uninstall.cmd" "%temp%\STuninst.cmd" 1>nul 2>&1 + copy "%UsrFolder%\share\streamtuner2\dev\uninstall.cmd" "%temp%\STuninst.cmd" "%temp%\STuninst.cmd" ) -echo | set /p=Do you want to uninstall Streamtuner2 for Windows? (y/n) +echo | set /p=Do you want to uninstall Streamtuner2 for Windows? [y/N] set /P INPUT=%=% -If /I NOT %INPUT% == Y exit +If /I NOT '%INPUT%' == 'Y' exit -echo | set /p=Do you want to keep your Streamtuner2 settings? (y/n) +echo | set /p=Do you want to keep your Streamtuner2 settings? [Y/n] set /P INPUT=%=% -If /I %INPUT% == N ( +If /I '%INPUT%' == 'N' ( echo Deleting personal settings... del "%Userprofile%\AppData\Roaming\streamtuner2\*.*" /F /S /Q ) - -echo | set /p=Do you want to keep your Python 2.7.12 installation? (y/n) +set INPUT= + +if '"%StreamripperFolder%"' NEQ '' ( + echo | set /p=Do you want to uninstall Streamripper? [y/N] + goto uninstallSR +) +goto uninstallPython + +:uninstallSR +set /P INPUT=%=% +If /I '%INPUT%' == 'Y' ( + echo Uninstalling Streamripper... + "%StreamripperFolder%\Uninstall.exe" /S + reg delete HKCU\SOFTWARE\Streamripper /f 1>nul 2>&1 + reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamripper /f 1>nul 2>&1 + reg delete HKLM\SOFTWARE\WoW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Streamripper /f 1>nul 2>&1 +) +set INPUT= + +:uninstallPython +echo | set /p=Do you want to keep your Python 2.7.12 installation? [Y/n] set /P INPUT=%=% -If /I %INPUT% == N ( - echo Removing LXML 2.3 - "%Python%\Removelxml.exe" -u "%Python%\lxml-wininst.log" - REM reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\lxml-py2.7 /f 1>nul +If /I '%INPUT%' == 'N' ( echo Removing PIL 1.1.7 "%Python%\RemovePIL.exe" -u "%Python%\PIL-wininst.log" - REM reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PIL-py2.7 /f 1>nul - echo Removing requests - "%Python%\scripts\pip.exe" uninstall requests -q <"%UsrFolder%\share\streamtuner2\dev\Y" 1>nul echo Removing pyquery 1.2.17 - "%Python%\scripts\pip.exe" uninstall pyquery -q <"%UsrFolder%\share\streamtuner2\dev\Y" 1>nul + "%Python%\scripts\pip.exe" uninstall pyquery -y -q + echo Removing LXML 2.3 + "%Python%\scripts\pip.exe" uninstall lxml -y -q + echo Removing requests + "%Python%\scripts\pip.exe" uninstall requests -y -q echo Removing cssselect - "%Python%\scripts\pip.exe" uninstall cssselect -q <"%UsrFolder%\share\streamtuner2\dev\Y" 1>nul + "%Python%\scripts\pip.exe" uninstall cssselect -y -q echo Removing PyGtk 2.24.2 MsiExec.exe /x{09F82967-D26B-48AC-830E-33191EC177C8} /qb-! echo Removing Python 2.7.12 MsiExec.exe /x{9DA28CE5-0AA5-429E-86D8-686ED898C665} /qb-! + reg delete HKCU\SOFTWARE\Python\PythonCore\2.7 /f 1>nul 2>&1 rd "%Python%" /S /Q ) echo Removing Streamtuner2 rd "%installFolder%" /S /Q @@ -90,9 +105,9 @@ echo Removing shortcuts rd "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Streamtuner2" /S /Q del "%USERPROFILE%\Desktop\Streamtuner2.lnk" 1>nul -reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamtuner2 /f 1>nul +reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamtuner2 /f 1>nul 2>&1 echo Finished uninstalling Streamtuner2 pause