@echo off

setlocal
pushd "%~dp0"

rem Remove stale marker if present
if exist "%SYSTEMDRIVE%\1201\Preserve-MBAM.marker" (
	del /f "%SYSTEMDRIVE%\1201\Preserve-MBAM.marker"
)

rem Set marker to prevent unintended MBAM removal
if exist "%PROGRAMFILES%\Malwarebytes\Anti-Malware\mbam.exe" (
	echo Previous Malwarebytes installation detected.
	echo. > "%SYSTEMDRIVE%\1201\Preserve-MBAM.marker"
)
if exist "%PROGRAMFILES(X86)%\Malwarebytes Anti-Malware\mbam.exe" (
	rem MBAM v2 installation
	echo Previous Malwarebytes [v2] installation detected.
	echo. > "%SYSTEMDRIVE%\1201\Preserve-MBAM.marker"
)

rem Install/Upgrade MBAM
echo Installing Malwarebytes...
start "" /wait mbam-setup.exe /VERYSILENT /NORESTART

popd
endlocal