Reputation: 1801
I have the following problem:
I run an XAMPP Apache server on a Windows 7 x64 machine which I want to remote access and then execute a program on. Right now I have two files in the htdocs directory, index.php and test.php.
index.php:
<a href="test.php">Click here</a>
test.php:
<?php
exec("C:\\xampp\\htdocs\\notepad.exe");
?>
The index.php opens up the test.php but thats where I get stuck. The browser now doesn't respond and just shows "waiting for localhost" until it times out.
I have spent hours trieing to figure out the problem but nothing helps.
Upvotes: 2
Views: 2362
Reputation: 1
As the comments on the PHP EXEC page mention, you should run it as a background process, else it will wait for result.
I know you asked for windows, but this will make it easier to port if you ever use something else. Although that seems hard with an exe file, but for other uses maybe. As I guess "notepad.exe" is just an example and not what you actually want to run.
Upvotes: 0
Reputation: 14173
As the comments on the PHP EXEC page mention, you should run it as a background process, else it will wait for result.
I know you asked for windows, but this will make it easier to port if you ever use something else. Although that seems hard with an exe
file, but for other uses maybe. As I guess "notepad.exe" is just an example and not what you actually want to run.
<?php
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
?>
Upvotes: 2