如何将ALL USER Directory设置为使用NSIS

时间:2015-09-03 09:46:21

标签: installer nsis

我正在尝试使用NSIS将文件安装到所有用户文档目录(Windows 7)。

在我的代码中我设置了“SetShellVarContext all”,但文件仍在当前用户目录中安装

请帮忙

这是我的代码

    # define installer name
    OutFile "installer.exe"

    # set desktop as install directory
    InstallDir $DOCUMENTS

    # default section start
    Section

    # define output path
    SetShellVarContext all
    SetOutPath $INSTDIR

    # specify file to go in output path
    File test.txt

    # define uninstaller name
    WriteUninstaller $INSTDIR\uninstaller.exe


    #-------
    # default section end
    SectionEnd

    # create a section to define what the uninstaller does.
    # the section will always be named "Uninstall"
    Section "Uninstall"

    # Always delete uninstaller first
    Delete $INSTDIR\uninstaller.exe

    # now delete installed file
    Delete $INSTDIR\test.txt

    SectionEnd

1 个答案:

答案 0 :(得分:1)

SetShellVarContext不会影响InstallDir属性,您必须手动设置$ InstDir:

Function .onInit
SetShellVarContext all
StrCpy $InstDir $Documents
FunctionEnd