How run .exe file in Inno Setup with parameters

2019-05-04 09:35发布

Please, I try run a .exe file that in cmd console runs in the following manner:

nameFile.exe -inf fileDriver.inf install

In the Inno Setup i have the follow:

var
command: Srtring;

Begin

command := 'nameFile.exe -inf fileDriver.inf install';
command := AddQuotes(command);
Exec(command, '', 'C:\pathOfFileName', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
S:= SysErrorMessage(ResultCode);
MsgBox(S, mbInformation, MB_OK);
end;

The message show that the parameters is invalid, how can run the exe file with the parameters?

1条回答
We Are One
2楼-- · 2019-05-04 10:33

Looking at your Exec call, you need to pass the command parameters to the second parameter of the function call. Try to use something like this instead:

...
Exec('nameFile.exe', '-inf fileDriver.inf install', 'C:\pathOfFileName', 
      SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
...

The Exec function is declared as:

function Exec(const Filename, Params, WorkingDir: String; 
  const ShowCmd: Integer; const Wait: TExecWait; 
  var ResultCode: Integer): Boolean;
查看更多
登录 后发表回答