无法使用NSIS编写注册表文件

时间:2016-01-20 18:21:59

标签: installer registry nsis

我有以下代码片段用于将注册表文件写入路径:

;Registry and SDK Setup  
Section "mySection"  
    SetOverwrite on  
    SetOutPath "C:\ProgramData\....\Gadgets"  
    File "{....KEYS...}.png"  
    File "{....KEYS...}.xml"  
    WriteRegStr HKLM "...\STC\Gadgets\{....KEYS...}" "toastAction""DisableToast"  
SectionEnd

上面的代码无法编写注册表文件。有人可以帮我找到问题吗?

1 个答案:

答案 0 :(得分:1)

您需要设置$INSTDIR变量以指示目标目录。 MUI 2有一个现成的页面,让用户选择目标文件夹。它被称为MUI_PAGE_DIRECTORY

!include "MUI2.nsh"
Name "Test"
Outfile "test.exe"
InstallDir "$LOCALAPPDATA\test"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section
    SetOutPath "$INSTDIR"
    ;Use File to copy files to destination folder.

SectionEnd