mO SharemO Share

"'<command>' is not recognized as an internal or external command, operable program or batch file" - Error message is shown while executing a Windows command through command prompt (cmd) or an executable program

SYMPTOMS


While running any windows command from the command prompt (e.g. XCOPY, SQLCMD, PING) or from inside a program (e.g. ODAC setup, AutoUpdate etc.) you may receive the above error where '<command>' stands for 'XCOPY' or 'PING' etc.

CAUSE


There are two types of commands that can be run in the Windows environment, namely 'internal' commands and 'external' commands. All internal commands are loaded into Windows memory at the time of system boot up and Windows can execute any internal command without any specific configuration. A few examples of internal commands will be CD (Change Directory), CLS (Clear Screen) etc. However, external commands are typically packaged as .EXE (executable file), .CMD (command file) or .BAT (batch file). Example of external commands are XCOPY.EXE (Extended Copy), PING (ping utility). Since external commands are packaged in a file, Windows needs to know where to find this file. To locate the external command file, Windows searches all folder locations saved in the PATH environment variable.

The above error is shown when any of the following is true:

  1. The PATH environment variable is not properly configured, i.e. the folder containing the command file is not found in any of the folder locations specified in the PATH variable. 
    (E.g. PING.EXE is located in C:\Windows\System32 but C:\Windows\System32; is not found in any of the folders specified in the PATH variable.)
  2. The PATHEXT environment variable is not configured properly. This variable identifies the default file extensions that Windows will assume when an external command is run without extensions. 
    (E.g. when XCOPY is given at the command prompt, Windows searches for a file named XCOPY.EXE in all the folders specified in the PATH variable.)

RESOLUTION


To resolve the above error - 

  1. Check if the folder containing the external command is included in the PATH environment variable. Add the folder path if it is not found.
    Refer: How To: View the value of Windows environment variables 
    Refer: How To: Set the PATH variable in environment variable in Windows

  2. Check the value of the PATHEXT environment variable. The value of this system variable is generally “.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC” (without the quotes). Some of the default extensions are added by programs installed in the target system and may not be applicable for you. Correct the anomalies in the PATHEXT variable if the ".COM;.EXE;.BAT;.CMD" extensions are not found with the values mentioned above.
    Refer How To: Set the PATH variable in environment variable in Windows

This should resolve your issue, in case you face it again please contact our Ginesys Care portal - https://care.ginesys.in/