Sign up ×

i read so many similar questions but nothing works with me

im using wamp 2.2 ,Apache 2.0 , PHP V5.3.8

safe_mode=off - disabled_functions deleted from php.ini i'm trying to exec


nothing happens and when i try


the windows shows weird message to execute calc in different user although i changed the user for the apache service to Administrator and i verify the user using


where is the problem?

share|improve this question
Is chrome.exe in your current working directory or the PATH variable? –  sandradev Jun 29 '12 at 22:31
when executing chrome.exe on CMD it works well –  Farok Ojil Jun 29 '12 at 22:35
i have to ask how are you running apache as Administrator, are you not running as a Service? and what OS as Windows Vista/7 does not have an Administration user –  Martin Barker Jun 29 '12 at 22:51
my user is the Administrator and my OS is win7 and i'm running the WAMP as admin and the apache service is running as admin –  Farok Ojil Jun 29 '12 at 22:59
@DaveRandom Windows 7 Does not have an "Administrator" Account it is a user group name, that contains the Administrator Elevation Privileges there is no Administrator User in Windows 7 or Vista. Its not like ubuntu where the root account still exists just locked out it, MS removed it for the Elevated Privileges System that has been used on Windows Domains For Years hence before hand and why another PC can Grant the Same Privileges to a User of another Windows 7/Vista Operating System on a LAN –  Martin Barker Jun 30 '12 at 23:12

2 Answers 2

Environment path for CMD and php shell might not be the same. You either have to give entire path of the file, or export the path of chrome.exe in php first

Also, I believe that chrome.exe opening a page requires XServer, php can't open graphical interfaces in shell. These commands are not passed to actual shell as a parent, so php file can't "launch" applications for you.

Please read specifics of the exec function: PHP exec Reference

Also try adding 2> errors.txt to see what are the errors if any in the execution of the programme.


The program needs to know what X server to connect to, and it needs to have permissions to connect to that server. You specify the X server with the DISPLAY environment variable; this will usually be set automatically if you are running the PHP program from a terminal in X, or from a GNOME panel or something similar; however, if you are running the PHP script in some other manner, it likely won't know what X server to connect to.

X has various ways of specifying permission to connect to a server, but the most common one is using a file called ".Xauthority" in the users home directory. Because only the user who is logged in at the X server can read this file, they are the only user who can run GUI programs. So, if you start the PHP user as the same user who is logged in at the X server, you shouldn't have any problem with permissions. However, if the PHP program is running as a different user, you will have to give that user permission to access the X server.

Reference: (I know that link is for linux and won't have exact same solution for Windows, but exec() still needs to know which X interface to refer to)

share|improve this answer
i tried the full path of chrome.exe nothing happens –  Farok Ojil Jun 29 '12 at 22:44
There's usually no X server in Windows. –  Emil Vikström Jun 29 '12 at 23:03
ok i get it .. i tried to make jar file that open chrome and it's work well but when i call it from php nothing happens .. is it because jar file consider as GUI program or what's the problem ? –  Farok Ojil Jun 30 '12 at 0:27
Did you try error redirection using yourcommand 2> errors.txt ? It'll show what error program is throwing, which might help better in understanding the problem –  Hrishikesh Jun 30 '12 at 12:12

Stop Apache running as a service.

When windows runs a service it it is not running directly as the user that started the server or manages due to this it could well be starting chrome in a service environment so you wont see it load on your desktop there are 2 ways to get around this

Stop apache service browse to your apache directory and run httpd.exe manualy then try your script it should work or if it is not required to be running though a web request so it not using anything from the browser you can allow it to work with c:\wamp\php\php.exe yourfile.php (your php path should be replaced for c:\wamp\php)

share|improve this answer

Your Answer


