Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How run .exe file in Inno Setup with parameters

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?

like image 375
Will86 Avatar asked Oct 06 '22 05:10

Will86


1 Answers

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;
like image 184
TLama Avatar answered Oct 10 '22 01:10

TLama