0

私の目標は、サイレント インストール ( /S param ) を使用して NSIS コマンド ライン パラメータをコピーされたセットアップに渡すときに、チェックまたはコード スニップを使用して依存関係があるかどうかを判断することです。

NSIS サンプル: http://nsis.sourceforge.net/Get_command_line_parameter_by_name

たとえば、3 つのパラメーターがある場合: Setup.exe /S param1="" param2="" param3=""

次のセクションを確認する方法:

${if} <Param1 is passed to Setup.exe> 
  <Param2 must ALSO be passed to Setup.exe>
${else}
  <Error message notifiing that Param1 is present, but dependent Param2 param is missing in CMD parameters>

ありがとうございました!

機能コード全体ではないにしても、少なくともコードの一部を共有していただければ幸いです。

4

1 に答える 1

0
outfile test.exe
requestexecutionlevel user
silentinstall silent ;always force silent in this sample
!include LogicLib.nsh
!include FileFunc.nsh

Function StripOptPrefix
Exch $0
Push $1
StrCpy $1 $0 1
${If} $1 == "="
${OrIf} $1 == ":"
    StrCpy $0 $0 "" 1
${EndIf}
Pop $1
Exch $0
FunctionEnd
!macro StripOptPrefix var
Push ${var}
call StripOptPrefix
Pop ${var}
!macroend

Section
${GetParameters} $0
${If} $0 == ""
    ;No parameters, lets run the tests
    ExecWait '"$exepath" /param1=foo'
    ExecWait '"$exepath" /param1=foo /param2=bar'
${Else}
    ${GetOptions} $0 "/param1" $1
    ${If} ${Errors}
        # /param 1 not used, do nothing?
    ${Else}
        ${GetOptions} $0 "/param2" $2
        ${If} ${Errors}
            MessageBox mb_iconstop "Missing /param2, required by /param1"
            Quit
        ${Else}
            !insertmacro StripOptPrefix $1
            !insertmacro StripOptPrefix $2
            MessageBox mb_ok "1=$1$\n2=$2"
        ${EndIf}
    ${EndIf}
${EndIf}
SectionEnd
于 2011-12-06T20:31:09.603 に答える