我正在尝试使用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
答案 0 :(得分:1)
SetShellVarContext
不会影响InstallDir
属性,您必须手动设置$ InstDir:
Function .onInit
SetShellVarContext all
StrCpy $InstDir $Documents
FunctionEnd