Creating installers for Verge3D plugins

From Verge3D Wiki
Revision as of 09:58, 17 August 2022 by Alexander (talk | contribs) (Created page with "Use the following NSIS script to create installers for your Puzzles plugins: <syntaxhighlight lang="NSIS"> !define APPNAME "Example Plugin" !define COMPANYNAME "YourCompany"...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Use the following NSIS script to create installers for your Puzzles plugins:

!define APPNAME "Example Plugin"
!define COMPANYNAME "YourCompany"
!define DESCRIPTION "Example Plugin Setup Wizard"
!define HELPURL "https://www.example.com/"
!define UPDATEURL "https://www.example.com/"
!define ABOUTURL "https://www.example.com/"

Unicode true

SetCompress off
SetCompressor /SOLID lzma

!include "MUI2.nsh"
 
InstallDir "$PROGRAMFILES64\ExamplePlugin"

# Installer/uninstaller's title bar
Name "${COMPANYNAME} ${APPNAME}"
OutFile "..\example-plugin.exe"

RequestExecutionLevel highest
 
!include LogicLib.nsh
 
# interface Settings

!define MUI_ABORTWARNING

!define MUI_WELCOMEPAGE_TITLE "Example Plugin installation"
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEPAGE_TEXT "This Setup Wizard will install Example Plugin on your computer."

!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Finish Text"

!define MUI_FINISHPAGE_TITLE "Installation is complete"
!define MUI_FINISHPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_TEXT "Thank you for choosing Example Plugin. Get started with the Startup Guide (click on the link below)."
!define MUI_FINISHPAGE_LINK "Open Startup Guide"
!define MUI_FINISHPAGE_LINK_LOCATION ${HELPURL}
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_NOAUTOCLOSE

# pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

Section
    SectionIn RO

    # use installation folder only for license and uninstaller
    SetOutPath "$INSTDIR"
    File LICENSE.txt

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Blender" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for Blender is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for 3ds Max" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for 3ds Max is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Maya" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D for Maya is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D Ultimate" "Install_Dir"
    ${IfNot} ${Errors}
        DetailPrint "Verge3D Ultimate is installed at: $0"
        SetOutPath "$0\puzzles\plugins\ExamplePlugin"
        File /r /x LICENSE.txt /x setup.nsi *.*
    ${EndIf}

    WriteRegStr HKCU "Software\YourCompany\Example Plugin" "Install_Dir" "$INSTDIR"

    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "DisplayName" "Example Plugin"
    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "UninstallString" "$INSTDIR\Uninstall.exe"
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "NoModify" 1
    WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin" "NoRepair" 1
 
    WriteUninstaller "$INSTDIR\Uninstall.exe"

SectionEnd


Section "Uninstall"

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Blender" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for 3ds Max" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D for Maya" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    ClearErrors
    ReadRegStr $0 HKCU "Software\Soft8Soft\Verge3D Ultimate" "Install_Dir"
    ${IfNot} ${Errors}
        RMDir /r "$0\puzzles\plugins\ExamplePlugin"
    ${EndIf}

    Delete "$INSTDIR\*.*"
    RMDir "$INSTDIR"

    DeleteRegKey HKCU "Software\YourCompany\Example Plugin"
    DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Example Plugin"
 
SectionEnd