Adjust the following function thus:

/**
 * Executes a dmtxread or dmtxwrite command using exec()/popen().
 */
function datamatrix_exec($command, $mode = NULL, array $options = array()) {
  if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
    $command = '"' . $command . '"';
  }
  foreach ($options as $k => $v) {
    $command .= ' --'. $k . ($v === TRUE ? '' : '='. escapeshellarg((string)$v));
  }
  $arguments = array_slice(func_get_args(), 3);
  $command = trim($command .' '. implode(' ', array_map('escapeshellarg', $arguments)));

  if (!$mode) {
    exec($command, $output, $result);
    return $result === 0 ? $output : FALSE;
  }
  return popen($command, $mode);
}

Comments

rconstantine’s picture

BTW, the paths admins enter would look something like this:

C:/Program Files/ImageMagick-6.6.6-Q8/dmtxwrite.exe

C:/Program Files/ImageMagick-6.6.6-Q8/dmtxread.exe

These cannot have quotes put around them or they won't validate.

Perhaps the documentation (and admin messages) could be updated to reflect this.