1

我正在运行使用 NSIS 完成的程序安装程序,但 /D 选项似乎不起作用(或者更好地在内部覆盖)。通过命令行我触发:

installer.exe /S /D=C:\Users\Public\installDir

NSIS代码是:

InstallDir "C:\Users\Public\${VERSIONSTR}"


Function xxxx
 ${If} $MultiUser.InstallMode == "AllUsers"      
 StrCpy $INSTDIR "C:\Users\Public\Dir1"
 ${EndIf}
 IfSilent 0 +20
   StrCpy $INSTDIR "C:\Userdata\Dir2"
FunctionEnd

使用的安装文件夹是“C:\Users\Public\Dir2”。即使我评论 IfSilent 块,安装文件夹也将是“C:\Users\Public\Dir1”,但绝不会通过命令行传递。我的脚本有什么问题?

4

1 回答 1

2
!include LogicLib.nsh
;InstallDir ; Do not use InstallDir at all so we can detect empty $InstDir
!define DEFDIR_MACHINE "$programfiles\foo"
!define DEFDIR_PERUSER "$localappdata\bar"
Function .onInit
${If} $InstDir == "" ; /D not used
    ${If} $MultiUser.InstallMode == "AllUsers"
        StrCpy $InstDir "${DEFDIR_MACHINE}"
    ${Else}
        StrCpy $InstDir "${DEFDIR_PERUSER}"
    ${EndIf}
    ${If} ${Silent}
        StrCpy $InstDir "c:\CrazySilentOverride"
    ${EndIf}
${EndIf}
FunctionEnd
于 2013-05-31T22:11:05.940 回答