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.

2 Answers2

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

Community
  • 1
  • 1
spinsch
  • 1,415
  • 11
  • 23
  • 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.. – Adam the Mediocre Aug 10 '14 at 17:35
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' );
Jared Henderson
  • 1,299
  • 3
  • 13
  • 21