Created windows related powershell & batch scripts for install/uninstall

This commit is contained in:
KRTirtho 2021-03-22 23:49:12 -07:00
parent fed4544b0e
commit 66e9e6ba8b
9 changed files with 127 additions and 0 deletions

BIN
assets/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -0,0 +1,39 @@
# Don't edit this file without understanding, this can lead to major damage to the system
# Use uninstall.bat to remove Spotube
Add-Type -AssemblyName System.IO.Compression.FileSystem
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
if(Test-Path "$ScriptDir\qode.exe"){
$WannaRemove = Read-Host -Prompt "Are you sure to uninstall?[y]Yes/[n]No"
$WannaRemove = $WannaRemove.Trim().ToLower()
if($WannaRemove -eq "y"){
echo "Removing all the contents"
Get-ChildItem $ScriptDir -Recurse | Remove-Item
$DeleteData = Read-Host -Prompt "Do you want to delete all data & caches?[y]Yes/[n]No"
$DeleteData = $DeleteData.Trim().ToLower()
if ($DeleteData -eq "y") {
echo "Deleting data & caches"
Remove-Item -Path "$Home\.config\spotube" -Recurse
Remove-Item -Path "$Home\.cache\spotube" -Recurse
echo "Deleted caches & data"
}
elseif($DeleteData -eq "n") {
echo "Ok, keeping those"
}
else{
throw "Wrong Option, use either 'y' or 'n', aborting..."
}
echo "Uninstall complete, just delete the Spotube folder now"
echo "Will miss you💕!"
}
elseif($WannaRemove -eq "n"){
echo "Thank god you didn't, quitting..."
}
else{
throw "Wrong Option, use either 'y' or 'n', aborting..."
}
}
else{
throw "Script isn't being executed desired location, aborting for abuse"
}

View File

@ -0,0 +1,3 @@
@echo off
Powershell.exe -Command "& {Start-Process Powershell.exe -ArgumentList '-ExecutionPolicy Bypass -File %~dp0make-install.ps1' -Verb RunAs}"

View File

@ -0,0 +1,79 @@
# Don't edit this file, this can cause serious damage
# Use install.bat to install Spotube
Add-Type -AssemblyName System.IO.Compression.FileSystem
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$shortcut_paths = @(
"$HOME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Spotube.lnk",
"$HOME\Desktop\Spotube.lnk"
)
# for creating shortcuts
function CreateShortcut {
$Target = "$ScriptDir\qode.exe"
$WshShell = New-Object -comObject WScript.Shell
echo "Creating shortcuts"
foreach($shortcut in $shortcut_paths){
echo $shortcut
$StartShortcut = $WshShell.CreateShortcut($shortcut)
$StartShortcut.TargetPath = $Target
$StartShortcut.WorkingDirectory = $ScriptDir
$StartShortcut.IconLocation = "$ScriptDir\dist\icon.ico"
$StartShortcut.Save()
}
}
$Spotube_Dir = "$Env:Programfiles\Spotube"
# extracts & installs spotube
function InstallSpotube {
param([bool]$PromptLocation)
$Spotube_Location=""
# checking if reinstalling
if($PromptLocation){
$Spotube_Location = Read-Host -Prompt "Give an absolute path (e.g C:\My Folder\) to install Spotube or leave it empty to install in {$Spotube_Dir}: "
}
# now creating/installing spotube
if(!$Spotube_Location.Trim()){
New-Item -Path $Env:Programfiles -Name "Spotube" -ItemType "directory"
[System.IO.Compression.ZipFile]::ExtractToDirectory("$ScriptDir\spotube.data", $Spotube_Dir)
}
else{
New-Item -Path Spotube_Location -Name "Spotube" -ItemType "directory"
[System.IO.Compression.ZipFile]::ExtractToDirectory("$ScriptDir\spotube.data", "$Spotube_Location\Spotube")
}
$WannaCreateShortcut = Read-Host -Prompt "Do you want to create shortcuts?[y]Yes/[n]No"
$WannaCreateShortcut = $WannaCreateShortcut.Trim().ToLower()
if($WannaCreateShortcut -eq "y"){
CreateShortcut
}
elseif($WannaCreateShortcut -eq "n"){
echo "Ok, skipping this part"
}
else{
throw "Wrong Option, use either 'y' or 'n', aborting..."
}
}
if(!(Test-Path $Spotube_Dir)){
InstallSpotube -PromptLocation $True
}
# reinstallation procedure
else{
echo "Spotube already exists in $Env:Programfiles\Spotube"
$WannaReplace = Read-Host -Prompt "Do you want to reinstall?[y]Yes/[n]No"
$WannaReplace = $WannaReplace.Trim().ToLower()
if($WannaReplace -eq "y"){
echo "Removing Old Spotube"
Remove-Item -Path "$Spotube_Dir" -Recurse
echo "Installing New Spotube"
InstallSpotube
}
elseif($WannaReplace -eq "n"){
echo "Keeping the older installation, quitting..."
}
else{
throw "Wrong Option, use either 'y' or 'n', aborting..."
}
}

View File

View File

@ -0,0 +1,3 @@
{
"distPath": ".\\dist"
}

View File

View File

@ -0,0 +1,3 @@
@echo off
powershell.exe -ExecutionPolicy Unrestricted -Command ". '%~dp0clear-installation.ps1'"