如何将 ALL USER 目录设置为使用 NSIS 创建的安装程序的输出目录

How to set the ALL USER Directory as an output directory for a installer created with 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

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

Function .onInit
SetShellVarContext all
StrCpy $InstDir $Documents
FunctionEnd