NSIS restrict folder installation

主宰稳场 提交于 2019-12-08 01:37:08

问题


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

回答1:


Use the .onVerifyInstDir callback function.

Edit:

Function .onVerifyInstDir
StrLen $0 $Desktop
StrCpy $0 $INSTDIR $0
StrCmp $0 $Desktop 0 PathGood
Abort
PathGood:
FunctionEnd


来源:https://stackoverflow.com/questions/9950968/nsis-restrict-folder-installation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!