Windows cmd.exe & was unexpected at this time

A botched program install, upgrade, or install such as Anaconda Python can make a Windows registry mis-entry that causes many commands to fail. The symptoms may include that simply trying to run “cmd.exe” COMSPEC fails with message including:

& was unexpected at this time

If this message occurs even when just opening a new Command Prompt window, the problem may be that the Windows Registry AutoRun is messed up. Check this in Registry Editor under:

HKCU\Software\Microsoft\Command Processor\AutoRun

and / or

HKLM\Software\Microsoft\Command Processor\AutoRun

On one system there was a bad entry:

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"