0

I am trying to run a test script to see if a bigger project I have in mind will work. On my wamp server, I have my index calling this separate php script:

<?php

exec("cd C:\Program Files (x86)\Notepad++");
exec("notepad++.exe");
echo "didn't crash";
?> 

All I need the program to do is open notepad++. I have tried putting a shortcut in the same directory at which it's called (www), running a shortcut from the desktop, and now accessing the exe itself. Every time I use it, it runs and says "didn't crash", yet it never opens notepad++.

The php manual for exec(http://php.net/manual/en/function.exec.php) shows an example that seems too simple, yet it works. So does the system() example.

All I need is access to the cmd so I can call on files. Right now it is just exe's, but it will eventually be jar's/py's that will post to text files.

3 Answers 3

1
<?php

$ret = exec('START C:\Program Files (x86)\Notepad++\Notepad++.exe', $output, $error);

// Debug
var_dump($ret);
var_dump($output);
var_dump($error);
?>

Update

maybe your php hasn't permissions to run commands on your wamp: https://stackoverflow.com/a/9161752/1721486

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, after trying your answer, it unfortunately didn't work, but It did lead me to something. I downloaded ProcMon, a sysinternal suite program, and it helped me find the process once it was called. I set up a shortcut in c:\ to avoid the filepath, which helped, and the cmd process is marked as a success, not blocked. Not sure what else is going on..
0

on a mac, you'd need the command to actually open the app, like:

exec( 'open SomeApp.app' );

I think on Windows you would use 'start' (?)

exec( 'start notepad++.exe' );

Comments

0

You said WAMP server, and I imagine you already checked this, but is Apache running as the logged-in user? Otherwise notepad is up on some desktop you cannot see.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.