[Lazarus] Confusion with TProcess on Windows
Michael Van Canneyt
michael at freepascal.org
Thu Aug 8 08:39:20 CEST 2013
On Thu, 8 Aug 2013, Richard Mace wrote:
> Hi All,
> I am baffled :)
> If I open a command prompt, change to the directory which contains plink.exe and run the command:
>
> plink -pw password root at 192.168.0.5 command
>
> The command works no problem, but if I do following in a TProcess I get a "flash" of a black window, then nothing!
>
> Process := TProcess.Create(nil);
> try
> sPSFTPFile := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0))) + 'plink.exe';
> Process.Executable := sPSFTPFile;
> S := '-pw ' + Password + ' ' + Username + '@' + IPAddress + ' ' + Command;
>
> Process.Parameters.Add(S);
Obviously this is wrong.
It should be:
With process.Parameters do
begin
Add('-pw');
Add(Password);
Add(Username+'@'+IPAddress);
Add(Command);
end;
Your example is specified as wrong almost verbatim in the documentation:
http://www.freepascal.org/docs-html/fcl/process/tprocess.parameters.html
Michael.
More information about the Lazarus
mailing list