[Fix] The term ‘scriptcs’ is not recognized as an internal or external command, operable program or batch file

This post contains a step by step guide to fix the error “The term ‘scriptcs’ is not recognized as an internal or external command, operable program or batch file” that you receive while running a C# program (.net core) in Visual Studio code using code runner extension.

Steps to replicate the ‘scriptcs’ not recognized error:

  1. Open Visual Studio code.
  2. In your workspace directory, create a new .Net project.
  3. To create a .Net project, type dot net new console in VS code terminal to create a console application.
  4. A Hello World C# program is created that outputs “Hello World” to console.
  5. If you run the newly created program using dotnet run command, it works and the console prints “Hello World”.
  6. Now, install the code runner extension for Visual Studio code.
    If you use code runner extension, you do not need to type the run command every time you want to run your program. With just a single click, all types of programs run.
  7. Open the extension panel in VS code and search for code runner.
  8. Click on Install button to install code runner extension.
  9. Open VS code explorer and open the .CS file
  10. Now, a “run code” option appears on the top-right corner of VS code.
    This button is provided by the code runner extension, and can run programs for almost all languages.
  11. Click on the “run code” button to run the program. This gives the error “The term ‘scriptcs’ is not recognized as an internal or external command, operable program or batch file“.

scriptcs‘ is a utility that helps in writing and executing C sharp code. The code runner extension calls the ‘scriptcs‘ command to run C# code by default.
To fix the ‘scriptcs’ command not found error, either install scriptcs on your computer or follow the below steps in this post.

Steps to fix “‘scriptcs’ is not recognized as an internal or external command” error:

  1. Open Settings in VS code.
  2. Under Extensions section, select the “Run code configuration“.
  3. Look for the “Run in Terminal” option and check it.
    This option appears once the code runner extension is installed and with this, the output is shown in the integrated terminal of VS code.
  4. In the same settings screen, on the top right corner, you have the “open json settings” button; open it.
    Or, you can open “user json setting” as well. Both are same.
  5. The settings.json file opens, let’s add a new entry here.
  6. At the bottom of the json file, type code-runner.executormap and select the suggested option.
    Whenever you run the code directly through the code runner, the commands that are run based on the language is listed in this executormap.
  7. Search for csharp in the list and scriptcs command is executed (whenever you run a C# prgram).
    "csharp": "scriptcs"
  8. Change this scriptcs to “dotnet run“.
    The new entry becomes – "csharp": "dotnet run"
  9. Save the settings.json file.
  10. Open your code file and run the code using code runner icon.

This time the program runs successfully as behind the scene, code runner is triggering “dotnet run” command instead of “scriptcs“.

That is how you can fix “‘scriptcs’ is not recognized as an internal or external command, operable program or batch file” error in Visual Studio code while running .Net core (C#) program. If you are still facing the error, let us know in the comments and we will try to help you out.

Cheers !!!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top