lazarusfpc

TAsyncProcess doesn't start with parametrs


I want run phantonJS executable from TProcess wuth my JS and some parametrs for it. But TAsyncProcess ignore my command line params.
PhandomJS docs says, that I must run my script in that order:

phantomjs.exe [phantom opts] jsfile.js [jsfile opts]

In code:

  fProc := TAsyncProcess.Create(nil);
  fProc.Options := [poNoConsole, poStderrToOutPut];
  fProc.ShowWindow := swoNone;
  fproc.StartupOptions := [suoUseShowWindow];
  fProc.OnTerminate := @privOnProcTerminated;
  fDebugFile := '';   
...
  fProc.CurrentDirectory := ExtractFilePath(fExecutable);
  fProc.Executable := fExecutable;
  fproc.Parameters.Add(fPhantomScript);
  fproc.Parameters.Add(IntToStr(fPort));
  fproc.Parameters.Add(fHost);
  fproc.Parameters.Add(fDebugFile);
  fProc.ShowWindow := swoShowNormal;
  fproc.StartupOptions := fproc.StartupOptions + [suoUseShowWindow];
  if not isRunning then
  begin
    fProc.Execute;
    Logger.Send('phantonJS launched.');
    Result := True;
  end    

The executable is launching, but I don't see, that's parametrs was applyed to process (via System Explorer), also script don't work as it must.

Why TAsyncProcess ignore my params? How to fix that?

Lazarus 1.4.4 from web-site. Target OS: Windows


Solution

  • I have tested that this generally works with Lazarus. I assume that the syntax of the parameters passed was wrong.

    As @Nested Type has said: You don't need to quote parameters. TProcess does that for you.