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

is not recognized as an internal or external command, operable program or batch file 해결방법

안녕하세요. cmd에 어떤 명령어를 입력했는데 위와 같은 문장이 나오더군요. 빨리 명령어를 입력하고 정보를 얻어서 무언가를 해야하는 상황이었는데 위와 같은 메시지가 나와서 작업을 못하게 되니 답답하더군요. 이 포스팅에서는 이에 대한 해결방법에 대해서 알아보고자 합니다.

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

먼저 내 PC -> C: -> Windows -> System32의 경로로 들어갑니다. 경로로 들어갔으면 사진에서 화살표로 표시한 부분을 클릭합니다. 그리고 해당 경로 주소를 복사합니다. Ctrl+C를 이용해서 복사하면 간편할것이라고 생각합니다.

경로를 복사했으면 이번에는 제어판 - 모든 제어판 항목 - 시스템을 클릭합니다.

시스템을 클릭하고 창이하나 뜨면 좌측에 있는 고급 시스템 설정을 클릭합니다.

고급 탭에서 환경 변수(N)...를 클릭합니다.

위와 같이 환경 변수 창이 뜨면 먼저 사용자 변수(U)에서 새로 만들기(N)를 클릭합니다. 클릭하면 우측과 같이 새 시스템 변수를 추가할 수 있는 창이 나오는데요. 여기에서 변수 이름에 Path, 변수 값에 아까 복사했던 경로를 붙여넣습니다. 그리고 확인을 클릭합니다.

그리고 바로 아래 쪽의 시스템 변수(S)에서도 새로 만들기(W)를 클릭하고 우측과 같은 창이 나오면 똑같이 입력하고 확인을 클릭합니다. 그리고 마지막에는 좌측 창의 확인을 클릭합니다.

이처럼 설정하고 다시 명령 프롬프트(cmd)에 접속하여 기존에 입력했던 명령어를 입력해봅니다. 그러면 is not recognized as an internal or external command, operable program or batch file 메시지가 안나올 것이라고 생각합니다. 저는 이와 같은 방법으로 문제를 해결했습니다. 왜 명령어를 입력했을때 위와 같은 메시지가 나오는지는 모르겠으나, 사용자의 입장에서 문제가 해결이 되니 그걸로 괜찮다는 생각이 들더군요. 이 방법이 도움이 되었으면 좋겠습니다.

Code of Conduct

  • I agree to follow this project's Code of Conduct

What happened?

I'm using the latest version (7.30.0) on Windows 11 (build 22000.527) with Windows Terminal.
I had recently set up CMD for some legacy usage, so I've installed CLink and tried to set up Oh-My-Posh with it.

It looks like OMP + CMD has an escape-path-characters issue (similar to the one OMP + Git Bash for Windows had).

I've created the following Clink Lua script (inside Clink's default scripts folder, aka C:\Program Files (x86)\clink):

load(io.popen('oh-my-posh --config="~/cli-theme.omp.json" --init --shell cmd'):read("*a"))()

And whenever starting a CMD session, I'm getting the following error:

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

Manual Fix

Creating a soft link to oh-my-posh.exe in a path without spaces (for example: C:/Utils/oh-my-posh.exe) and changing the CLink's Lua script:

load(io.popen('C:/Utils/oh-my-posh.exe --config="~/cli-theme.omp.json" --init --shell cmd'):read("*a"))()

Probably removing oh-my-posh and reinstalling it to a path without spaces (for example: "C:\oh-my-posh") should also solve the issue. But haven't tried.

Theme

aliens theme

What OS are you seeing the problem on?

Windows

Which shell are you using?

other (please specify)

Log output

Version: 7.30.0 Segments: ConsoleTitle(false) - 0 ms - session(true) - 0 ms -  ronam@RON-AM-PC  path(true) - 0 ms -  ~ shell(true) - 0 ms -  uni text(true) - 0 ms -  no config exit(true) - 0 ms -   Run duration: 2.1717ms Cache path: C:\Users\ronam\AppData\Local\oh-my-posh Logs: 2022/03/01 20:06:55 Args duration: 0s, args: 2022/03/01 20:06:55 Args duration: 0s, args: 2022/03/01 20:06:55 Args duration: 0s, args: 2022/03/01 20:06:55 Shell duration: 0s, args: 2022/03/01 20:06:55 debug: Getenv 2022/03/01 20:06:55 Getenv duration: 0s, args: OMP_CACHE_DISABLED 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 debug: Getenv 2022/03/01 20:06:55 Getenv duration: 0s, args: SSH_CONNECTION 2022/03/01 20:06:55 debug: Getenv 2022/03/01 20:06:55 Getenv duration: 0s, args: SSH_CLIENT 2022/03/01 20:06:55 Root duration: 0s, args: 2022/03/01 20:06:55 Shell duration: 0s, args: 2022/03/01 20:06:55 ErrorCode duration: 0s, args: 2022/03/01 20:06:55 IsWsl duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 User duration: 0s, args: 2022/03/01 20:06:55 Host duration: 0s, args: 2022/03/01 20:06:55 GOOS duration: 0s, args: 2022/03/01 20:06:55 TemplateCache duration: 548.8µs, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 Args duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 GOOS duration: 0s, args: 2022/03/01 20:06:55 GOOS duration: 0s, args: 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 PathSeparator duration: 0s, args: 2022/03/01 20:06:55 GOOS duration: 0s, args: 2022/03/01 20:06:55 IsWsl duration: 0s, args: 2022/03/01 20:06:55 StackCount duration: 0s, args: 2022/03/01 20:06:55 TemplateCache duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 Shell duration: 0s, args: 2022/03/01 20:06:55 TemplateCache duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 TemplateCache duration: 0s, args: 2022/03/01 20:06:55 debug: Pwd C:\Users\ronam 2022/03/01 20:06:55 Pwd duration: 0s, args: 2022/03/01 20:06:55 debug: Home C:\Users\ronam 2022/03/01 20:06:55 ErrorCode duration: 0s, args: 2022/03/01 20:06:55 TemplateCache duration: 0s, args: 2022/03/01 20:06:55 TemplateCache duration: 0s, args: 2022/03/01 20:06:55 debug: Getenv C:\Users\ronam\AppData\Local 2022/03/01 20:06:55 Getenv duration: 0s, args: LOCALAPPDATA 2022/03/01 20:06:55 CachePath duration: 544.9µs, args: 'C:/Program' is not recognized as an internal or external command, operable program or batch file. 'C:/Program' is not recognized as an internal or external command, operable program or batch file.

How do you fix C :\ Program is not recognized as an internal or external command?

You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.

How do you fix make is not recognized as an internal or external command operable program or batch file?

If you already have MinGW installed in Windows 7, just simply do the following: Make another copy of C:\MinGW\bin\mingw32-make.exe file in the same folder. Rename the file name from mingw32-make.exe to make.exe . Run make command again.

Which is not recognized as an internal or external command?

The “not recognized as internal command” error usually occurs because the computer cannot find the executable file it is trying to start. However, you can provide the full path to your executable and then it should run without any problem. Launch a Command Prompt window on your PC.

What is an internal or external command?

An internal command is embedded into the command.com file, and an external command is not and requires a separate file to operate. For example, if your computer does not have the fdisk.exe file and you try using the fdisk command, you will receive a "Bad command or file name" error message.