''未被识别为内部或外部命令,可操作程序或批处理文件 [英] '' is not recognized as an internal or external command, operable program or batch file

查看:333
本文介绍了''未被识别为内部或外部命令,可操作程序或批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试从Windows cmd.exe终端运行mycommand.exe时,都会出现此错误:

无法将"mycommand.exe"识别为内部或外部命令,可操作程序或批处理文件.

然后

当我尝试运行C:\Program Files\My-App\Mobile.exe

时,我也遇到了类似的错误

"C:\ Program"未被识别为内部或外部命令,可操作程序或批处理文件"

解决方案

这是在Stackoverflow上看到的一个非常常见的问题.

这里的重要部分不是错误中显示的命令,而是实际错误告诉您的内容.

关于为什么收到此错误的快速细分.

cmd.exe作为终端窗口,它依赖于输入和系统环境变量,以便执行您要求它执行的操作.它不知道所有内容的位置,也不知道何时区分由空格分隔的命令或可执行文件名称,例如 space tab 或带有空格作为切换变量.

我该如何解决:

实际命令/可执行文件失败

首先我们确定是否已实际上安装了可执行文件?如果是,请继续进行其余操作;否则,请先安装.

如果您尝试从cmd.exe运行任何可执行文件,则需要告诉cmd.exe该文件的位置.有两种方法可以做到这一点.

  1. 指定文件的完整路径.

    "C:\My_Files\mycommand.exe"

  2. 将文件的位置添加到您的环境变量中.

转到:
------>控制面板->系统->高级系统设置->环境变量

System Variables窗口中,找到path并选择 edit

现在只需将您的路径添加到字符串的末尾,用分号;分隔为:

;C:\My_Files\

保存更改并退出.您需要确保已关闭的所有cmd.exe窗口都已关闭,然后重新打开以允许其重新导入环境变量. 现在,您应该能够从cmd.exe内的任何路径运行mycommand.exe,因为环境可以知道它的路径.

C:\Program或类似内容失败

这是一个非常简单的错误.在cmd.exe终端中,空格后的每个字符串被视为一个不同的命令,您只需要将整个路径括在双引号中,以使cmd.exe将该字符串视为一个字符串,而不是单独的命令.

因此要执行C:\Program Files\My-App\Mobile.exe只需运行:

"C:\Program Files\My-App\Mobile.exe"

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'

解决方案

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"

这篇关于''未被识别为内部或外部命令,可操作程序或批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆