Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'' is not recognized as an internal or external command, operable program or batch file

Tags:

batch-file

cmd

Whenever I try and run mycommand.exe from my windows cmd.exe terminal, I get this error:

''mycommand.exe' is not recognized as an internal or external command, operable program or batch file'

Then

I also experienced a similar error when I tried to run C:\Program Files\My-App\Mobile.exe

''C:\Program' is not recognized as an internal or external command, operable program or batch file'

like image 659
Gerhard Avatar asked Jan 18 '18 12:01

Gerhard


People also ask

Is not Recognised as internal or external command?

The “Python is not recognized as an internal or external command” error is encountered in the command prompt of Windows. The error is caused when Python's executable file is not found in an environment variable as a result of the Python command in the Windows command prompt.

Is not recognized as an internal or external command operable program or batch file bat?

The “is not recognized as an internal command” error usually occurs because the computer can't find the executable that you're asking it to launch. However, you can provide it with the full path to your executable file and it should then be able to run it without any issues. Launch a Command Prompt window on your PC.

Which is not recognized as an internal or external command Windows 10?

If you meet the error “command is not recognized as an internal or external command, operable program or batch file” problem in Command Prompt in Windows 10, the reason may be that the Windows Environment Variables are messed up.


2 Answers

This is a very common question seen on Stackoverflow.

The important part here is not the command displayed in the error, but what the actual error tells you instead.

a Quick breakdown on why this error is received.

cmd.exe Being a terminal window relies on input and system Environment variables, in order to perform what you request it to do. it does NOT know the location of everything and it also does not know when to distinguish between commands or executable names which are separated by whitespace like space and tab or commands with whitespace as switch variables.

How do I fix this:

When Actual Command/executable fails

First we make sure, is the executable actually installed? If yes, continue with the rest, if not, install it first.

If you have any executable which you are attempting to run from cmd.exe then you need to tell cmd.exe where this file is located. There are 2 ways of doing this.

  1. specify the full path to the file.

    "C:\My_Files\mycommand.exe"

  2. Add the location of the file to your environment Variables.

Goto:
------> Control Panel-> System-> Advanced System Settings->Environment Variables

In the System Variables Window, locate path and select edit

Now simply add your path to the end of the string, seperated by a semicolon ; as:

;C:\My_Files\ 

Save the changes and exit. You need to make sure that ANY cmd.exe windows you had open are then closed and re-opened to allow it to re-import the environment variables. Now you should be able to run mycommand.exe from any path, within cmd.exe as the environment is aware of the path to it.

When C:\Program or Similar fails

This is a very simple error. Each string after a white space is seen as a different command in cmd.exe terminal, you simply have to enclose the entire path in double quotes in order for cmd.exe to see it as a single string, and not separate commands.

So to execute C:\Program Files\My-App\Mobile.exe simply run as:

"C:\Program Files\My-App\Mobile.exe" 
like image 58
Gerhard Avatar answered Sep 28 '22 17:09

Gerhard


When you want to run an executable file from the Command prompt, (cmd.exe), or a batch file, it will:

  • Search the current working directory for the executable file.
  • Search all locations specified in the %PATH% environment variable for the executable file.

If the file isn't found in either of those options you will need to either:

  1. Specify the location of your executable.
  2. Change the working directory to that which holds the executable.
  3. Add the location to %PATH% by apending it, (recommended only with extreme caution).

You can see which locations are specified in %PATH% from the Command prompt, Echo %Path%.

Because of your reported error we can assume that Mobile.exe is not in the current directory or in a location specified within the %Path% variable, so you need to use 1., 2. or 3..

Examples for 1.

C:\directory_path_without_spaces\My-App\Mobile.exe 

or:

"C:\directory path with spaces\My-App\Mobile.exe" 

Alternatively you may try:

Start C:\directory_path_without_spaces\My-App\Mobile.exe 

or

Start "" "C:\directory path with spaces\My-App\Mobile.exe" 

Where "" is an empty title, (you can optionally add a string between those doublequotes).

Examples for 2.

CD /D C:\directory_path_without_spaces\My-App Mobile.exe 

or

CD /D "C:\directory path with spaces\My-App" Mobile.exe 

You could also use the /D option with Start to change the working directory for the executable to be run by the start command

Start /D C:\directory_path_without_spaces\My-App Mobile.exe 

or

Start "" /D "C:\directory path with spaces\My-App" Mobile.exe 
like image 45
Compo Avatar answered Sep 28 '22 18:09

Compo