Skip to content

Instantly share code, notes, and snippets.

@supermarsx
Last active April 15, 2026 17:12
Show Gist options
  • Select an option

  • Save supermarsx/0d388ba63fe390fcad15c70e64d404a4 to your computer and use it in GitHub Desktop.

Select an option

Save supermarsx/0d388ba63fe390fcad15c70e64d404a4 to your computer and use it in GitHub Desktop.
Fix Outlook asking for credentials when doing on-prem

Fix Outlook credential prompts in on-prem Exchange setups

This small batch script applies a few Outlook/Exchange registry values that can help stop repeated credential prompts in on-premises Exchange environments.

What it does

It sets these values for the current user:

  • Forces modern auth for Exchange autodiscover
  • Excludes the explicit Microsoft 365 autodiscover endpoint
  • Disables Outlook's credential prompt policy value
  • Closes Outlook so the change can take effect cleanly

Script

@echo off
setlocal

echo Applying Outlook / Exchange registry fixes...

reg add "HKCU\Software\Microsoft\Exchange" /v AlwaysUseMSOAuthForAutoDiscover /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Office\16.0\Outlook\AutoDiscover" /v ExcludeExplicitO365Endpoint /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Policies\Microsoft\Office\16.0\Outlook\Security" /v PromptForCredentials /t REG_DWORD /d 0 /f

echo Closing Outlook...
taskkill /f /im outlook.exe >nul 2>&1

echo Done.
endlocal

One-liner version

reg add "HKCU\Software\Microsoft\Exchange" /v AlwaysUseMSOAuthForAutoDiscover /t REG_DWORD /d 1 /f && reg add "HKCU\Software\Microsoft\Office\16.0\Outlook\AutoDiscover" /v ExcludeExplicitO365Endpoint /t REG_DWORD /d 1 /f && reg add "HKCU\Software\Policies\Microsoft\Office\16.0\Outlook\Security" /v PromptForCredentials /t REG_DWORD /d 0 /f && taskkill /f /im outlook.exe >nul 2>&1

Notes

  • Intended for Outlook 2016 / 2019 / Microsoft 365 Apps using the 16.0 registry path.
  • Applies to the current user only (HKCU).
  • If your environment enforces these settings via Group Policy, those policies may override manual changes.
  • Restart Outlook after running the script.

Revert

reg delete "HKCU\Software\Microsoft\Exchange" /v AlwaysUseMSOAuthForAutoDiscover /f
reg delete "HKCU\Software\Microsoft\Office\16.0\Outlook\AutoDiscover" /v ExcludeExplicitO365Endpoint /f
reg delete "HKCU\Software\Policies\Microsoft\Office\16.0\Outlook\Security" /v PromptForCredentials /f

Disclaimer

Use this only if you understand how your Outlook authentication and autodiscover flow is configured. In some environments, credential prompts are caused by server-side auth, autodiscover, certificate, or policy issues rather than local client settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment