user2167582
user2167582

Reputation: 6368

Cannot run php from command line when use environment variable

I have windows 8, and whenever I run php from the installed directory, then it works without a problem, but whenever I set the environment variable to that directory, and run php --version, then a win-8 bar appears:

This app can't run on your PC
To find a version for your PC, check with the software publisher

Has anyone encountered a similar issue or found a solution for this?

Attached below are the commands that i ran:

K:\Users\username>php
Access is denied.

K:\Users\username>php
Access is denied.

K:\Users\username>php --version
Access is denied.

K:\Users\username>F:/
'F:/' is not recognized as an internal or external command,
operable program or batch file.

K:\Users\username>F:

F:\>php
Access is denied.

F:\>cd Program

F:\Program>cd php-5.5.6-x86 

F:\Program\php-5.5.6-x86>ls
dev            iculx51.dll             libpq.dll         php.gif
ext            icutest51.dll           libsasl.dll       php.ini-development
extras         icutu51.dll             license.txt       php.ini-production
glib-2.dll     icuuc51.dll             news.txt          php5.dll
gmodule-2.dll  install.txt             phar.phar.bat     readme-redist-bins.txt
icudt51.dll    libeay32.dll            pharcommand.phar  snapshot.txt
icuin51.dll    libenchant.dll          php-cgi.exe       ssleay32.dll
icuio51.dll    libenchant_ispell.dll   php-win.exe
icule51.dll    libenchant_myspell.dll  php.exe

F:\Program\php-5.5.6-x86>php --version
PHP 5.5.6 (cli) (built: Nov 12 2013 11:33:16)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies

F:\Program\php-5.5.6-x86>

By the way the same thing occurs in wampserver php, so it probably dont have anything to do with 86 bit install or 5.5.6 unstable.

I also tried run as admin not working either, same output.

Upvotes: 1

Views: 2011

Answers (2)

Shiko
Shiko

Reputation: 2624

I have same issue before and tried several things, one of the things that works for me that the php.exe file has been changed by some program and it's size was 0 kb, I reverted back by bringing the php.exe file from backup folder I have.

may be it is not solution for all people, but just check the php file hasn't been changed.

Upvotes: 1

Jan Schejbal
Jan Schejbal

Reputation: 4033

You might have two PHP executables, one of them (F:\Program\php-5.5.6-x86\php.exe) is working, one of them (which is on your path) is not. Check the directories in your PATH for the broken one.

Upvotes: 1

Related Questions