Run Windows Command from PHP Site

General discussion on PHP
Post Reply
Posts: 36
Joined: Mon Nov 03, 2014 3:49 pm
Location: Concord, North Carolina

Run Windows Command from PHP Site

Post by jord1322 » Fri Sep 29, 2017 2:34 pm


I'm trying to figure out how to setup an application to be able to kickoff (open) a desktop application, specifically Google Earth in this case, from my site (it's a company intranet site). I found some information about using file_put_contents() to create a .bat file with the command, 'start "" "C:\Program Files (x86)\Google\Google Earth Pro\client\googleearth.exe" /b "" "googleearth.exe"' and then using the exec() command to execute it, but I keep getting a 126 error saying that it could not be executed. I have confirmed that the file is being created, and when I open it directly from the folder on the server it does exactly as expected and opens Google Earth so the command itself works apparently, but I'm having no luck in getting the exec() command on the site to launch it.

I've heard that it might could be a permissions issues, but my understanding of much of the server stuff is vague at best, and I'm not sure what to do. Some of the other things I've looked at mention that they only open the application in the background, which is not enough for what I'm needing, I need it to actually open up the GUI for the user. Any guidance on how to accomplish this would be appreciated.
Jordon Greene
PHP Full Stack Developer

Posts: 1
Joined: Wed Oct 04, 2017 1:20 pm

Re: Run Windows Command from PHP Site

Post by ally6142 » Wed Oct 04, 2017 1:34 pm

All things considered, its a pleasant post. I lean toward Windows, dependably. Attempted a great deal of times other OS's yet they cannot do simple things like Windows do.

Posts: 19
Joined: Thu Jan 11, 2018 5:45 pm

Re: Run Windows Command from PHP Site

Post by andr8558 » Thu Jan 25, 2018 9:13 pm

Very useful commands for everyone on Windows. I personally am on Linux but I'm sure someone else will find it useful :) 7 little words answers

Post Reply