Search code examples
windowsinstallationnsis

How to Add a Desktop Shortcut Option on Finish Page in NSIS installer?


I'm trying to create an installer using NSIS Modern User Interface for the first time. I would like to know how I can add an option (checkbox) for users to select to have a desktop shortcut created on the Finish Page (the last screen of the installer) in addition to the "Run XXXX" option that's already there.


Solution

  • If you are not using readme checkbox on the finish page, you can use it to perform whatever action you want:

    Function finishpageaction
    CreateShortcut "$desktop\foo.lnk" "$instdir\foo.exe"
    FunctionEnd
    
    !define MUI_FINISHPAGE_SHOWREADME ""
    !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
    !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
    !define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
    !insertmacro MUI_PAGE_FINISH