@echo off
if /I %0 EQU "%~dpnx0" (set LAUNCH=1) else (set LAUNCH=0)
set PROP=ExcludeExplicitO365Endpoint
set KEY=Microsoft\Office\16.0\Outlook\AutoDiscover
echo Disabling Office 365 AutoDiscover...
reg add HKCU\Software\%KEY% /v %PROP% /t REG_DWORD /d 1 /f /reg:32 >nul 2>nul
reg add HKCU\Software\Policies\%KEY% /v %PROP% /t REG_DWORD /d 1 /f /reg:32 >nul 2>nul
reg add HKCU\Software\%KEY% /v %PROP% /t REG_DWORD /d 1 /f /reg:64 >nul 2>nul
reg add HKCU\Software\Policies\%KEY% /v %PROP% /t REG_DWORD /d 1 /f /reg:64 >nul 2>nul
if %ERRORLEVEL% GTR 0 (
if %LAUNCH% GTR 0 color 0e
echo ERROR: This script failed to run. Please make sure to Run As Administrator
reg delete HKCU\Software\%KEY% /v %PROP% /f /reg:32 >nul 2>nul
reg delete HKCU\Software\Policies\%KEY% /v %PROP% /f /reg:32 >nul 2>nul
reg delete HKCU\Software\%KEY% /v %PROP% /f /reg:64 >nul 2>nul
reg delete HKCU\Software\Policies\%KEY% /v %PROP% /f /reg:64 >nul 2>nul
echo Changes have been reverted.
if %LAUNCH% GTR 0 pause
goto :EOF
)
echo Successfully disabled Office 365 AutoDiscover!
echo Please restart your comptuer.
if %LAUNCH% GTR 0 pause