NSIS 限制文件夹安装 [英] NSIS restrict folder installation
本文介绍了NSIS 限制文件夹安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个 NSIS 安装程序,我需要能够阻止安装到用户错误"文件夹(即 $SYSDIR、$WINDIR、$DESKTOP 等...)
I have a NSIS installer I am working on that I need to be able to prevent installation to the "user error" folders (i.e. $SYSDIR, $WINDIR, $DESKTOP etc... )
我希望他们能够选择安装路径,但如果他们选择了上面列出的位置,则只需禁用下一步按钮.我到处搜索,找不到这个问题的答案.
I want them to be able to chose a installation path but just have the next button be disabled if they chose a location as listed above. I have searched everywhere and can't find an answer to this one.
我试图使用它,但我仍然可以安装到桌面:
I was trying to use this but I can still install to desktop:
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE MyDirLeave
!insertmacro MUI_PAGE_DIRECTORY
...
Function MyDirLeave
Push $0
StrLen $0 $DESKTOP
StrCpy $0 $INSTDIR $0
StrCmp $0 $DESKTOP 0 proceed
MessageBox MB_ICONSTOP|MB_OK \
"Installation on DESKTOP is not allowed, choose another directory"
Abort
proceed:
Pop $0
FunctionEnd
推荐答案
使用 .onVerifyInstDir 回调函数.
Function .onVerifyInstDir
StrLen $0 $Desktop
StrCpy $0 $INSTDIR $0
StrCmp $0 $Desktop 0 PathGood
Abort
PathGood:
FunctionEnd
这篇关于NSIS 限制文件夹安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文