Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows

"A command is not recognized as an internal or external command" แก้ยังไง?

เคยพิมพ์ 'CMD', 'DISM' ใน Run Prompt แล้วเปิดทันที ไหนว่า Windows หาตำแหน่งโปรแกรมได้ยังไง? เหมือน Shortcut ที่รู้ Path โปรแกรม Windows เก็บรายการ Path ของโปรแกรมระบบทั่วไป ไว้ใน Windows Environment Variables หาก Path นี้มีปัญหา โปรแกรมจะไม่ทำงาน บทความนี้ช่วย Troubleshoot ข้อผิดพลาด "is not recognized as an internal or external command, operable program, or batch file"

A command is not recognized as an internal or external command

Troubleshooting โปรแกรม ต้องเช็คก่อนว่ามีจริง ไป C:\Windows\System32\ ดู หรือค้นหา EXE ใน System32 ยืนยันมีอยู่ แล้วค่อยแก้

แก้ไข Environment Variables

Win+X เลือก System > ซ้ายมือ Advanced system setting > Environment Variables

 A command is not recognized as an internal or external command  แก้ยังไง?

Under System Variables หา Path คลิก EDIT

สำคัญ: Copy String ทั้งหมดไป Notepad ก่อน เผื่อผิดพลาด ค่อยวางกลับ

หา Path 'C:\Windows\System32' หากไม่มี ให้เพิ่ม Semi-colon (;) ท้ายสตริง  A command is not recognized as an internal or external command  แก้ยังไง?

คลิก OK บันทึก ออก แล้ว Reboot (Path โหลดตอนบูท)

ลองรันโปรแกรมที่ Error เดิม ดูแก้ได้ไหม

Pro-tip: หากมี Custom Batch Files อยู่ในโฟลเดอร์ ให้เพิ่ม Path โฟลเดอร์นั้น ตอนรันแค่พิมพ์ชื่อก็ Launch ได้ (Programmer ใช้บ่อย)

Internal vs External Command คืออะไร?

Internal Command: พร้อมใน Windows ทำงานจาก Windows Terminal/CMD
External Command: ไม่พึ่ง System Variables/OS มี Library ของตัวเอง

ทำไงให้ External Command ใช้ได้ใน Windows Terminal?

ต้องเพิ่ม Path ของโปรแกรมใน Terminal Settings คือ ใส่ใน System Variables Path Terminal จะหาเจอตอน Execute (เช่น Flutter ต้องเพิ่ม Path)

 A command is not recognized as an internal or external command  แก้ยังไง?