简体   繁体   中英

How to set the ALL USER Directory as an output directory for a installer created with NSIS

I am trying to install a file to ALL USER DOCUMENTS Directory(windows 7) using NSIS.

In my code i am setting "SetShellVarContext all" but still the files are getting installed at current user directory

Please help

Here is my code

    # 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 does not affect the InstallDir attribute, you must manually set $InstDir:

Function .onInit
SetShellVarContext all
StrCpy $InstDir $Documents
FunctionEnd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM