dotnet is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
2 min

banner

# dotnet is not recognized as an internal or external command

The error "'dotnet' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

  1. Not having .NET installed.
  2. Not having .NET added to your PATH environment variable.

dotnet is not recognized as internal or external command

shell
'dotnet' is not recognized as an internal or external command, operable program or batch file. The term 'dotnet' is not recognized as the name of a cmdlet, function, script file, or operable program.

To install .NET and add it to your PATH environment variable:

  1. Go to the .NET downloads page and click on the ".NET SDK" button to download the installer.

download dotnet installer

  1. Start the installer and click on the "Install" button.

start dotnet installer

  1. If you already have .NET installed, click on the "Repair" button instead.

start dotnet installer click repair

  1. Make sure to close any existing command prompts and PowerShell instances for the PATH variable to get updated.

  2. Open a new CMD shell and try running the dotnet command.

cmd
dotnet --version dotnet new console -o MyApp cd MyApp

windows run dotnet command

If the error persists, you have to manually add dotnet to your PATH environment variable.

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Click on "New" and then click "Browse".

click new browse

  1. Your dotnet directory is most likely located under C:\Program Files\dotnet.
location
C:\Program Files\dotnet
  1. Add the path to dotnet and click on "OK" twice to confirm.

  2. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Open a new CMD shell and try running the dotnet command.

cmd
dotnet --version dotnet new console -o MyApp cd MyApp

dotnet create new console app

# Conclusion

To solve the error "'dotnet' is not recognized as an internal or external command, operable program or batch file", make sure:

  1. You have .NET installed on your Windows machine.
  2. You have .NET added to your PATH environment variable.
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.