34

‘php.exe’ is not recognized as an internal or external command, operable program or batch file.

Why does that error occur even though I've added PHP to my environment variables?

My environment variable PATH is shown below:

C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\PC ............... Files\QTSystem\;A:\xampp\php\php.exe

I'm using Windows 7.

Sai Nikhil
  • 1,237
  • 2
  • 15
  • 39
  • This needs much more information. Can you show your PATH environment variable? What OS are you on? – Pekka Dec 11 '11 at 13:30
  • 1
    I think he's on Windows... anyway you need to have the correct PATH environment variable – haynar Dec 11 '11 at 13:31
  • http://bobschwarz.com/quick-tip-adding-mysql-and-php-to-your-windows-path/ should probably help, check that you've added it correctly aswell, please show us your PATH environment var. – lfxgroove Dec 11 '11 at 13:35
  • For troubleshooting needs, here is a checklist: [XXX is not recognized as an internal or external command, operable program or batch file](http://robertmarkbramprogrammer.blogspot.de/2008/01/xxx-is-not-recognized-as-internal-or.html) – hakre Mar 13 '13 at 07:17

10 Answers10

45
A:\xampp\php\php.exe

The PATH environment variable must contain paths only, not file names.

Make that

A:\xampp\php
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
29

it is very easy to do
You need to also add php.exe
Adding this path:
windows key + pause
click on Advance system settings
click Environment Variable
System variables part -> Path -> Edit and the add
C:\wamp\bin\php\php5.3.8;
close you cmd prompt if its open
It's Done!

24

I think you need to change it to A:\xampp\php\ and just leave it there, then it will search the directory for the file, also: have you tried calling just php instead of php.exe and check that the directory is correct.

lfxgroove
  • 3,778
  • 2
  • 23
  • 33
  • 1
    Don't forget to restart the computer after setting environment variables. – grgvn Apr 02 '15 at 11:23
  • 10
    You do not need to restart the computer to pick up environment variables... you only need to re-open the terminal window. – CashIsClay Apr 30 '15 at 00:36
17

enter image description here

View above screen shot for setup enviroment variable in window 7

Note:- After setup enviroment variable please restart you computer then its will work fine

daniula
  • 6,898
  • 4
  • 32
  • 49
Motilal Soni
  • 346
  • 2
  • 6
6

Shouldn't the last part be: C:\xampp\php\ ? Unless you remapped your drives, A is the floppy disk. :)

Also, you need to specify the folder, not the exe file itself.

Tudor
  • 61,523
  • 12
  • 102
  • 142
5

My case am Using Bitnami Ruby Stack apache Web server ,

  1. Pressed Windows key + Pause/Break Button
  2. Clicked advanced system settings
  3. Click Environment Variables
  4. Under System variables > edit PATH variable by adding C:\Bitnami\rubystack-1.9.3-24\php
  5. Click Ok to close the Environment Variable window
  6. Close your command prompt if open

    *(Proceed to 7. to confirm if php is installed)

  7. Press Windows Key + R button to open your cmd
  8. Type php -v to view your php version Confirm installed php version
Duncan O. N.
  • 778
  • 12
  • 24
5

Set PHP as environment variable from System as below to run it from CMD

1)Windows key + Pause
2)Click on Advanced system settings
3)Now click on Environment Variables.. button  
4)In system variable section search for Path and edit it as D:\wamp\bin\php\php5.3.13;(If one needs to append it to some already exits value then start path with;)
5)Now open CMD and run command PHP from any path where you don’t have PHP installed , in my case it’s C drive.
6)We can check above set Path from CMD using Path command also.
Digisha
  • 355
  • 3
  • 5
4

If you have installed WAMP server, then your path can vary. For example, I installed WAMP and the path to my php.exe turned out to be:

C:\wamp\bin\php\php5.5.12\php.exe

To make it work, I entered the following path in the PATH variable of the System Variables:

C:\wamp\bin\php\php5.5.12

Once done, I restarted command prompt and everything worked fine.

So the path can vary depending upon how you installed PHP. If you would like to install WAMP server and have it install other essential packages like PHPMyAdmin, etc. you may do so from: wampserver.com

Devner
  • 6,825
  • 11
  • 63
  • 104
2

In my case, environment path is C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\Php; and it works for me.

If I simply add C:\xampp\php\ dint work for me.

I hope if someone facing this issue can try this suggestion.

0

This happened to me and I found why.

Xampp can't run properly depending on your UAC settings.

Try to do this:

  1. Log in as administrator (running cmd.exe as administrator isn't enough)

  2. Execute cmd.exe or equivalent

  3. type php -version

DoukeN
  • 33
  • 7