Forum > General

SOLVED: Exception class 'EProcess', message "Failed to execute :267"

(1/2) > >>

puzzled:
Under Windows 10 I am trying to run ImageMagick on a graphic file.  I use TProcess for this purpose, and put handling of TProcess in its own procedure.  I get the following Debugger Exception Notification:

Project project1 raised exception class 'EProcess' with message:
Failed to execute  : 267
At address 4E68F2


The code, triggered by clicking a button, looks like

procedure TForm1.btnTestClick(Sender: TObject);
var
  MCurrentDirectory: string;
  MExecutable: string;
  MParameters: array of string;
begin
  MCurrentDirectory:= '"C:\Users\puzzled\downloads\graphics stuff\sample images"';
  MExecutable:= '"C:\Program Files\ImageMagick\magick.exe"';
  MParameters:= ['"C:\Users\puzzled\Documents\Lazarus\Resource files\arrow.png"',
                 '-alpha', 'set',
                 '-background', 'none',
                 '-rotate', '-44',
                 '"C:\Users\puzzled\downloads\graphics stuff\processed images\arrow44.png"'];
  TProcessHandling(MCurrentDirectory,
                   MExecutable,
                   MParameters);
end;   

procedure TForm1.TProcessHandling(MCurrentDirectory: string;
                                  MExecutable: string;
                                  MParameters: array of string);
var
  RunProgram: TProcess;
  s:string;
begin
  RunProgram := TProcess.Create(nil);
  RunProgram.CurrentDirectory:=MCurrentDirectory;
  RunProgram.Executable:=MExecutable;
  for s in MParameters do
    RunProgram.Parameters.Add(s);
  // Wait until done
  RunProgram.Options := RunProgram.Options + [poWaitOnExit];
  // Run ImageMagick
  RunProgram.Execute;     <--- Exception takes place here
  Runprogram.Free;
end; }


This DOS command, including double quote marks, works without error when run manually:

"C:\Program Files\ImageMagick\magick.exe" "C:\Users\puzzled\Documents\Lazarus\Resource files\arrow.png" -alpha set -background none -rotate 44 "C:\Users\puzzled\downloads\graphics stuff\processed images\arrow44.png"

Thank you for your guidance

Fibonacci:
267 is ERROR_DIRECTORY

Remove all quote marks from MCurrentDirectory, MExecutable and MParameters

Thaddy:
nope:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Mparameters.AddStrings( ['"C:\Users\puzzled\Documents\Lazarus\Resource files\arrow.png"',                 '-alpha', 'set',                 '-background', 'none',                 '-rotate', '-44',                 '"C:\Users\puzzled\downloads\graphics stuff\processed images\arrow44.png"']);Mparameters is - afaik - not overloaded to accept the strings directly. use AddStrings.
in this case the quotation marks are necessary, but make sure the paths exist.

puzzled:
REMOVING THE DOUBLE QUOTES WAS THE SOLUTION.
(How do I mark this as solved?)

Thank you!

Thaddy:
That can not be right on windows...
keep it open.

Navigation

[0] Message Index

[#] Next page

Go to full version