Skip to content

Commit

Permalink
Enhance uninstallation script and improve comments (#4)
Browse files Browse the repository at this point in the history
* Enhance uninstallation script and improve comments

Details of Changes:
- Added delayed expansion using `setlocal enabledelayedexpansion` to allow variables to be updated within loops and blocks.
- Corrected variable usage for accurate counting of removal operations.
- Improved error handling during Spotify uninstallation process.
- Utilized a loop to remove Spotify data folders from both AppData roaming and local AppData.
- Improved deletion process for "SpotifyUninstall.exe" if present.
- Enhanced comments to provide clearer explanations of code sections.
- Enhances the script by improving variable naming.
  • Loading branch information
relvinarsenio authored Aug 19, 2023
1 parent 6efca14 commit 8a597ec
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions Uninstall-Spotify.bat
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
@echo off

set a=0
set b=0
setlocal enabledelayedexpansion

REM Reset permissions for Spotify Update folder
if exist "%localappdata%\Spotify\Update" (
icacls "%localappdata%\Spotify\Update" /reset /T > NUL 2>&1
)

if exist "%appdata%\Spotify\Spotify.exe" (
set actions=0

REM Uninstall Spotify if it exists
if exist "%appdata%\Spotify\Spotify.exe" (
start "" /wait "%appdata%\Spotify\Spotify.exe" /UNINSTALL /SILENT
set /a b=%a% + 1
set /a actions+=1
)

timeout /t 1 > NUL 2>&1

if exist "%appdata%\Spotify" (
rd /s/q "%appdata%\Spotify" > NUL 2>&1
set /a b=%a% + 1
)
timeout /t 1 > NUL 2>&1

if exist "%localappdata%\Spotify" (
rd /s/q "%localappdata%\Spotify" > NUL 2>&1
set /a b=%a% + 1
REM Remove Spotify data folders
for %%d in ("%appdata%\Spotify" "%localappdata%\Spotify") do (
if exist "%%d" (
rd /s/q "%%d" > NUL 2>&1
set /a actions+=1
)
)

REM Delete SpotifyUninstall.exe if it exists
if exist "%temp%\SpotifyUninstall.exe" (
del /s /q "%temp%\SpotifyUninstall.exe" > NUL 2>&1
set /a b=%a% + 1
set /a actions+=1
)

if !actions! == 0 (
echo Spotify is not installed or not found
) else (
echo Spotify has been successfully uninstalled
)

if %b% == 0 echo Spotify not found
if %b% NEQ 0 echo Spotify removed
pause & exit

0 comments on commit 8a597ec

Please sign in to comment.