Home > Software engineering >  NSIS - How to make "Install" button always to be enabled
NSIS - How to make "Install" button always to be enabled

Time:12-27

I removed info for available space but the install button is still disabled when there is no enough space for the installation itself. I want to make "install" button always enabled. I tried this but with no success:

Function .onInit
  Call enableInstallBtn
FunctionEnd

Function enableInstallBtn
    GetDlgItem $0 $hWndParent 1 ; Get button handle
    EnableWindow $0 1
FunctionEnd

enter image description here

CodePudding user response:

.onInit is executed before the UI exists. The documentation tells you to set dirverify to leave:

RequestExecutionLevel User
InstallDir $temp

!include MUI2.nsh
!include LogicLib.nsh

!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE verifydir
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Function verifydir
GetInstDirError $0
${If} $0 = 1
  MessageBox MB_IconStop "Invalid installation directory!"
  Abort
${EndIf}
FunctionEnd

Section
AddSize 999999999 ; I'm huge
SectionEnd
  • Related