Can’t Open CMD.exe After Uninstalling Python/Anaconda; Exit Code 1

After uninstalling Python/Anaconda on your Windows computer, Command Prompt may not open. When you run cmd.exe, it flashes on the screen and immediately quits. Also, running DISM and SFC (to repair corrupt system files), repairing Windows installation, and running a thorough malware scan may not fix the issue.

Also, when you open Command Prompt via the Terminal menu in Visual Studio Code, the following error (Error 1: “Incorrect function”) occurs:

The terminal process "C:\WINDOWS\System32\cmd.exe" terminated with exit code: 1.

vscode cmd.exe error 1

If you had enabled conda init powershell and later uninstalled Anaconda, PowerShell might report the following error at every start:

The term 'C:\ProgramData\Anaconda3\Scripts\conda.exe' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\Ramesh\Documents\WindowsPowerShell\profile.ps1:3 char:4

The profile.ps1 file would have the following code in it, which auto-starts (PowerShell hook) whenever you launch PowerShell:

#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "C:\ProgramData\Anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression


This issue occurs due to an incorrect and leftover Autorun registry value after uninstalling Python.

autorun command processor python

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command ProcessorAutorun REG_SZ "if exist"

The value data might read “if exist” which CMD.exe executes at launch and closes automatically. Your Python/Anaconda installation added the registry value. However, you should be able to launch Command Prompt correctly by running “cmd.exe /d“.

/D  – Disable execution of AutoRun commands from the registry (see below)

  • If /D was NOT specified on the command line, then when CMD.EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if either or both are present, they are executed first.
    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun


    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

The PowerShell error (“‘conda.exe’ is not recognized”) is caused by the script file profile.ps1, which was generated by the “conda init powershell” command you ran earlier. The script file will be located at "%Userprofile%\Documents\WindowsPowerShell\profile.ps1".


Command Prompt

To resolve the Command Prompt issue, delete the Autorun registry key. The Autorun value doesn’t exist by default in Windows and can be deleted.

  1. Open an admin Command Prompt window. To do so, type cmd.exe /d in Start/Run dialog, and press Ctrl + Shift + Enter. (Ref: Start Programs Elevated from Run Dialog)
  2. In the admin Command Prompt, type the following commands:
    reg.exe delete "HKCU\SOFTWARE\Microsoft\Command Processor" /v "Autorun" /f

    and then:

    reg.exe delete "HKLM\SOFTWARE\Microsoft\Command Processor" /v "Autorun" /f

    In case you receive the following error, please ignore it:

    ERROR: The system was unable to find the specified registry key or value.
  3. Exit the Command Prompt window.

You should be able to launch cmd.exe (with or without the /d parameter) now.

PowerShell or Terminal Error

To fix the “conda.exe is not recognized as the name of a cmdlet” error in PowerShell, delete the “profile.ps1” file located under your “\Documents\WindowsPowerShell\” directory.

One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded in 2005.

5 thoughts on “Can’t Open CMD.exe After Uninstalling Python/Anaconda; Exit Code 1”

  1. i can’t guarantee this was the reason but shortly after following this advice my laptop stopped working completely so be cautious 🙂


Leave a Comment