0

I have referenced How to get an output of an Exec'ed program in Inno Setup?. But my txt file always empty.
Here is my script:

[Code] 
function MyTest(): Boolean;
Var
  TmpFileName: String;
  ExecStdout: AnsiString;
  ResultCode: Integer;
begin
  TmpFileName := 'C:\Users\My\Desktop\123.txt';
  Exec('C:\Users\My\Desktop\devcon.exe', 'help find > "' + TmpFileName + '"', '', SW_SHOW, 
    ewWaitUntilTerminated, ResultCode);
  if LoadStringFromFile(TmpFileName, ExecStdout) then
  begin
    MsgBox(ExecStdout, mbInformation, MB_OK);
  end;           
  //DeleteFile(TmpFileName);
  Result := true;
end;

function InitializeSetup(): boolean;
begin
  MyTest;
  Result := true;
end;
Assam
  • 179
  • 1
  • 13
  • This is not the code from the question your reference. Where is the `cmd.exe`? – Martin Prikryl Mar 07 '19 at 07:23
  • 1
    Your question seems to be a duplicate of [How does output redirection work in Inno Setup?](https://stackoverflow.com/q/11441938/850848) – Martin Prikryl Mar 07 '19 at 07:24
  • @MartinPrikryl Yes..but I'm not very clear about that answer. – Assam Mar 07 '19 at 07:46
  • What is `{cmd} /c actual-command-line > output-file` mean? – Assam Mar 07 '19 at 07:47
  • 1
    It means: run `actual-command-line` and redirect its output to `output-file`. – Martin Prikryl Mar 07 '19 at 10:37
  • @MartinPrikryl, I solved this problem. Here is my code: `Exec('cmd.exe', '/C ' + ExpandConstant('{tmp}\devcon.exe') + ' help find > ' + ExpandConstant('{tmp}\123.txt'), '', SW_SHOW, ewWaitUntilTerminated, ResultCode);` Thanks a lot. – Assam Mar 08 '19 at 01:26

0 Answers0