I get an Error while communication vie ssh (plink.exe) lazarus / 34-Windows ---------------------------------------------------------------------- kluesi · 2018-11-22 21:41 Hi I use the following procedure to execute a process: function GetDosOutput(CommandLine: string; Work: string = 'C:\'): string; var   SA: TSecurityAttributes;   SI: TStartupInfo;   PI: TProcessInformation;   StdOutPipeRead, StdOutPipeWrite: THandle;   WasOK: Boolean;   Buffer: array[0..255] of AnsiChar;   BytesRead: Cardinal;   WorkDir: string;   Handle: Boolean; begin   Result := '';   with SA do begin     nLength := SizeOf(SA);     bInheritHandle := True;     lpSecurityDescriptor := nil;   end;   CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);   try     with SI do     begin       FillChar(SI, SizeOf(SI), 0);       cb := SizeOf(SI);       dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;       wShowWindow := SW_HIDE;       hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin       hStdOutput := StdOutPipeWrite;       hStdError := StdOutPipeWrite;     end;     WorkDir := Work;     Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),                             nil, nil, True, 0, nil,                             PChar(WorkDir), SI, PI);     CloseHandle(StdOutPipeWrite);     if Handle then       try         repeat           WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);           if BytesRead > 0 then           begin             Buffer[BytesRead] := #0;             Result := Result + Buffer;           end;         until not WasOK or (BytesRead = 0);         WaitForSingleObject(PI.hProcess, INFINITE);       finally         CloseHandle(PI.hThread);         CloseHandle(PI.hProcess);       end;   finally     CloseHandle(StdOutPipeRead);   end; end;      ----------------------------------------------------------- I tried this CommandLine: plink.exe  -batch -ssh -2 -l XXXXXXX -pw YYYYYYYY -m c:\Users\XXXXXX\command.sh SERVER The file command.sh contains only one line: echo "Hi" 1>&2; I don't know exactly why I have to redirect the output, but it works. I started the programm with Debugger and everything is ok. If I start the xyz.exe I get the following Error Message: Unable to read from standard input: Das Handle ist ungültig. What do I wrong Thank Kluesi ---------------------------------------------------------------------- Leledumbo · 2018-11-27 19:48 CreateProcess should return a BOOL (alias of LongBool), not a Boolean. Boolean can only hold boolean with ordinal value of 0 and 1, while BOOL can hold 32-bit unsigned integer (0 = false, anything else is true). When assigned to the former, non-0 value will be converted into 1, I believe. Hence, you get invalid handle error.