@ECHO OFF
::Set the working directory
set "workingdir=%~dp0"
::Switch to working directory

echo.
choice /c yn /m "Remove current version of BlueStacks?"
if %errorlevel% equ 1 CALL wmic product where "Name like '%blue%'" call uninstall && REG DELETE HKLM\SOFTWARE\BlueStacks /va /f

net stop BstHdAndroidSvc /y 
taskkill /F /IM HD-Agent.exe >nul 2>&1 
taskkill /F /IM HD-BlockDevice.exe >nul 2>&1 
taskkill /F /IM HD-Network.exe >nul 2>&1 
taskkill /F /IM HD-Service.exe >nul 2>&1 
taskkill /F /IM HD-SharedFolder.exe >nul 2>&1 
taskkill /F /IM HD-UpdaterService.exe

RD /S /Q "C:\Program Files (x86)\BlueStacks"
RD /S /Q "C:\Program Files\BlueStacks"
RD /S /Q "C:\ProgramData\BlueStacks"

CD %temp%

for /D %%f in (*bluestacks*) do rd /S /Q %%f
for /D %%f in (*bst*) do rd /S /Q %%f

echo.
echo.
echo Now install BlueStacks by clicking on the Installer.
echo.
echo.

pause