Windows Command Prompt instant error on open

A botched program install, upgrade, or uninstall such as Anaconda Python can make a Windows registry mis-entry that causes many commands to fail. Simply trying to run “cmd.exe” COMSPEC instantly fails with:

& was unexpected at this time

or

Process exited with code 1

If this message occurs when just opening a new Command Prompt window, the problem may be in the Windows Registry. Check Registry Editor values:

HKCU\Software\Microsoft\Command Processor\AutoRun

and

HKLM\Software\Microsoft\Command Processor\AutoRun

Example 1

A system had a bad Autorun value:

if exist

This was corrected by emptying the Autorun value (or deleting the Autorun key).

Example 2

A system had a bad Autorun value:

if exist & if exist "%USERPROFILE%\miniconda3\condabin\conda_hook.bat" "%USERPROFILE%\miniconda3\condabin\conda_hook.bat"

It was fixed by correcting to:

if exist "%USERPROFILE%\miniconda3\condabin\conda_hook.bat" "%USERPROFILE%\miniconda3\condabin\conda_hook.bat"