diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d05a489..4ad5e2d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,17 +16,17 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up environment + - name: Prepare release version id: prep run: | - # Use current date-time to generate unique tag version VERSION="v$(date +'%Y.%m.%d-%H%M%S')" echo "version_tag=$VERSION" >> $GITHUB_OUTPUT - - name: Create ZIP archive + - name: Create ZIP structure run: | - mkdir release - cp wowBackup.ps1 run_wow_backup.bat README.md release/ + mkdir -p release/scripts + cp scripts/wowBackup.ps1 scripts/uninstall_wow_backup.ps1 release/scripts/ + cp run_wow_backup.bat uninstall_run_wow_backup.bat README.md release/ cd release zip -r ../WoWBackup_${{ steps.prep.outputs.version_tag }}.zip . diff --git a/README.md b/README.md index 4dac0e4..3e4c39e 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,17 @@ This will let you choose folders again and reconfigure the scheduler. 🧹 Uninstalling / Removing the Task +| `uninstall_run_wow_backup.bat` | Double-click to uninstall | + To remove the scheduled task manually: Run in Powershell as admin: Unregister-ScheduledTask -TaskName "WowUI_Backup" -Confirm:$false -To reset everything, delete: - - wowUI_config.json - - The scheduled task (WowUI_Backup) +## šŸ“ Folder Structure - Any backup .zip files \ No newline at end of file +| Folder/File | Description | +|-------------|-------------| +| `scripts/wowBackup.ps1` | Main backup script | +| `scripts/uninstall_wow_backup.ps1` | Uninstalls the scheduled task and config | +| `run_wow_backup.bat` | Double-click to run the backup | +| `uninstall_run_wow_backup.bat` | Double-click to uninstall | diff --git a/run_wow_backup.bat b/run_wow_backup.bat index 60cd72c..e856eea 100644 --- a/run_wow_backup.bat +++ b/run_wow_backup.bat @@ -2,7 +2,7 @@ :: Batch file to launch wowBackup.ps1 with admin rights :: Set the full path to your PowerShell script -set scriptPath=%~dp0wowBackup.ps1 +set scriptPath=%~dp0scripts\wowBackup.ps1 :: Check if run from Task Scheduler (SESSIONNAME usually is "Console" or missing in Scheduled Tasks) setlocal EnableDelayedExpansion diff --git a/scripts/uninstall_wow_backup.ps1 b/scripts/uninstall_wow_backup.ps1 new file mode 100644 index 0000000..e75d1d4 --- /dev/null +++ b/scripts/uninstall_wow_backup.ps1 @@ -0,0 +1,30 @@ +# Prompt for elevation if not already admin +if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` + [Security.Principal.WindowsBuiltinRole]::Administrator)) { + Write-Host "Restarting with administrative privileges..." + Start-Process powershell "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit +} + +Write-Host "Uninstalling WoW UI Backup setup..." + +# Remove Scheduled Task +$taskName = "WowUI_Backup" +if (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue) { + Unregister-ScheduledTask -TaskName $taskName -Confirm:$false + Write-Host "āœ… Scheduled task '$taskName' removed." +} else { + Write-Host "ā„¹ļø No scheduled task named '$taskName' found." +} + +# Remove Config File +$configPath = Join-Path (Split-Path $PSScriptRoot -Parent) "wowUI_config.json" +if (Test-Path $configPath) { + Remove-Item $configPath -Force + Write-Host "āœ… Config file removed: $configPath" +} else { + Write-Host "ā„¹ļø No config file found at: $configPath" +} + +Write-Host "`nāœ… Uninstall complete. CLick X in top right corner to close..." +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") diff --git a/wowBackup.ps1 b/scripts/wowBackup.ps1 similarity index 98% rename from wowBackup.ps1 rename to scripts/wowBackup.ps1 index f135a7b..c27943f 100644 --- a/wowBackup.ps1 +++ b/scripts/wowBackup.ps1 @@ -1,5 +1,5 @@ # Define path to config file -$configPath = "$PSScriptRoot\wowUI_config.json" +$configPath = Join-Path (Split-Path $PSScriptRoot -Parent) "wowUI_config.json" # Function to select folder function Select-Folder { diff --git a/uninstall_run_wow_backup.bat b/uninstall_run_wow_backup.bat new file mode 100644 index 0000000..4205980 --- /dev/null +++ b/uninstall_run_wow_backup.bat @@ -0,0 +1,13 @@ +@echo off +:: Launch the uninstall script with admin rights + +set scriptPath=%~dp0scripts\uninstall_wow_backup.ps1 + +>nul 2>&1 "%SystemRoot%\system32\cacls.exe" "%SystemRoot%\system32\config\system" +if '%errorlevel%' NEQ '0' ( + echo Requesting administrator privileges... + powershell -Command "Start-Process '%~f0' -Verb runAs" + exit /b +) + +powershell -ExecutionPolicy Bypass -File "%scriptPath%"