How do you pass in parameters to the Inno Setup co

2019-03-24 09:27发布

It was suggested in the IS newsgroup to use /D= but using the iscc.exe that came with version 5.2.3 I get an "Unknown option:" error.

Then in the script, how do you use the value of the command line parameter?

标签: inno-setup
3条回答
做个烂人
2楼-- · 2019-03-24 09:47

If you want to parse command line arguments from code in inno, then use a method similar to this. Just call the inno script from the command line as follows:

C:\MyInstallDirectory>MyInnoSetup.exe -myParam parameterValue

Then you can call the GetCommandLineParam like this wherever you need it:

myVariable := GetCommandLineParam('-myParam');

//==================================================================

{ Allows for standard command line parsing assuming a key/value organization }
function GetCommandlineParam (inParam: String):String;
var
  LoopVar : Integer;
  BreakLoop : Boolean;
begin
  { Init the variable to known values }
  LoopVar :=0;
  Result := '';
  BreakLoop := False;

  { Loop through the passed in arry to find the parameter }
  while ( (LoopVar < ParamCount) and
          (not BreakLoop) ) do
  begin
    { Determine if the looked for parameter is the next value }
    if ( (ParamStr(LoopVar) = inParam) and
         ( (LoopVar+1) < ParamCount )) then
    begin
      { Set the return result equal to the next command line parameter }
      Result := ParamStr(LoopVar+1);

      { Break the loop }
      BreakLoop := True;
    end

    { Increment the loop variable }
    LoopVar := LoopVar + 1;
  end;
end;

Hope this helps...

查看更多
干净又极端
3楼-- · 2019-03-24 09:52

From the Inno Setup helpfile:

Inno Setup Preprocessor replaces the standard Inno Setup Command Line Compiler (ISCC.exe) by an extended version. This extended version provides extra parameters to control Inno Setup Preprocessor.

The "extra parameters" include the /d option.

查看更多
混吃等死
4楼-- · 2019-03-24 09:57

You do, as MicSim says, need the preprocessor. It's included in the latest ISPack. Once it's installed, iscc supports /D.

You can then use the values defined like this (assuming you'd done /DVERSION_NAME=1.23):

AppVerName=MyApplication v{#VERSION_NAME}
查看更多
登录 后发表回答