Inno Setup仅返回用户指定的命令行开关

时间:2016-03-03 17:06:42

标签: inno-setup pascalscript

支持函数GetCmdTail将作为单个字符串传递给Setup或Uninstall的所有命令行参数返回。这会产生:

  

/ SL5 =“$ A808E8,550741730,269824,D:\ Setup.exe”/ DEBUGWND = $ 6A0ACA / verysilent / suppressmsgboxes / closeapplications / restartapplications / norestart

是否有其他函数或简单方法只返回用户指定的命令行开关:

  

/ verysilent / suppressmsgboxes / closeapplications / restartapplications   / norestart更新日志文件

在这种特殊情况下,同时排除/DEBUGWND条目和/或任何其他未被用户指定的参数?

1 个答案:

答案 0 :(得分:2)

基于我用run an elevated installer的类似代码:

function GetUserCmdTail: string;
var
  I: Integer;
  S: string;
begin
  for I := 1 to ParamCount do
  begin
    S := ParamStr(I);
    { Filter all internal Inno Setup switches }
    if (CompareText(Copy(S, 1, 5), '/SL5=') <> 0) and
       (CompareText(Copy(S, 1, 10), '/DEBUGWND=') <> 0) and
       (CompareText(Copy(S, 1, 10), '/SPAWNWND=') <> 0) and
       (CompareText(Copy(S, 1, 11), '/NOTIFYWND=') <> 0) and
       (CompareText(S, '/DETACHEDMSG') <> 0) and
       (CompareText(S, '/DebugSpawnServer') <> 0) then
    begin
      Result := Result + AddQuotes(S) + ' ';
    end;
  end;
end;