The code in the Nsi file:
;NSIS Version 2.0 Script using Modern Interface
Name "MyInventorAdd-in"
!define PRODUCT "My Inventor Add-in"
!define ADDIN_NAME "MYInventorAdd-in" ;Name that shows up in the Inventor Addin Manager
!define ADDIN_DLL "bin\MYInventorAdd-in.dll" ;The Addin Dll In my program
;!define File1 "bin\LineControls.dll" ;Exstra files I need, With my program
!define ADDIN_DLL1 "MYInventorAdd-in.dll" ;The Addin Dll
;!define File_1 "LineControls.dll" ;
!define DESCRIPTION "My Inventor Add-in" ;Description that shows up in the Inventor Addin Manager
!define UNINST_EXE "UninstMyInventorAdd-in.exe" ;Name of the uninstall program
!define INST_FILE "InstMyInventorAdd-in.exe" ;The install program name
!define INST_DEF_DIR "C:\Program Files\Autodesk\Macros\MyInventorAdd-in" ;C:\Program Files\ will be prepended
!include WordFunc.nsh
!insertmacro WordReplace
OutFile "${INST_FILE}"
;------------------------------------------------------
;---Check for regasm
Section "Checkregasm" checkregasm
IfFileExists $WINDIR\Microsoft.NET\Framework\v2.0.50727\regasm.exe Found NoFound
NoFound:
IfFileExists $WINDIR\Microsoft.NET\Framework64\v2.0.50727\regasm.exe Found1 NoFound1
NoFound1:
;---exit file is Installed
MessageBox MB_OK "Can't Install The File: regasm.exe does not existing!"
Quit
Found:
Found1:
SectiOnEnd
!include "MUI.nsh"
;--------------------------------
;Configuration
;General
OutFile "${INST_FILE}"
;Folder selection page
InstallDir "${INST_DEF_DIR}"
;Remember install folder
InstallDirRegKey HKCU "Software\${PRODUCT}" ""
;--------------------------------
;Modern UI Configuration
;Pages
;!define MUI_FINISHPAGE_NOAUTOCLOSE ;comment out if you want to jump to the finish page
!insertmacro MUI_PAGE_WELCOME
!ifdef LIC_FILE
!insertmacro MUI_PAGE_LICENSE "${LIC_FILE}"
!endif
!insertmacro MUI_PAGE_DIRECTORY
; !insertmacro MUI_PAGE_COMPONENTS ;if you have components to select
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro WordReplace
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Language Strings
;Descriptions used in the Component selection dialog if used
;LangString DESC_SecCopyUI ${LANG_ENGLISH} "Copy the ${INST_FILE} file to the application folder."
;--------------------------------
;Data
!ifdef LIC_FILE
LicenseData "${LIC_FILE}"
!endif
;--------------------------------
;Installer Sections
Section "InstallAddin" SecCopyUI
;ADD YOUR OWN STUFF HERE!
SetOutPath "$INSTDIR"
File "${ADDIN_DLL}"
File "${File1}"
!ifdef VIEW_DOC
File /nonfatal "${VIEW_DOC}"
!endif
;Store install folder
WriteRegStr HKCU "Software\${PRODUCT}" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\${UNINST_EXE}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ADDIN_NAME}" "DisplayName" "${PRODUCT}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ADDIN_NAME}" "UninstallString" "$INSTDIR\${UNINST_EXE}"
SectionEnd
;----------------------
Section "Registry" SetReg
IfFileExists $WINDIR\Microsoft.NET\Framework\v2.0.50727\regasm.exe Found11 NoFound11
Found11:
execwait '$WINDIR\Microsoft.NET\Framework\v2.0.50727\regasm.exe /codebase "$INSTDIR\${ADDIN_DLL1}"'
NoFound11:
IfFileExists $WINDIR\Microsoft.NET\Framework64\v2.0.50727\regasm.exe Found12 NoFound12
Found12:
execwait '$WINDIR\Microsoft.NET\Framework64\v2.0.50727\regasm.exe /codebase "$INSTDIR\${ADDIN_DLL1}"'
NoFound12:
SectionEnd
;----------------------
Section "View Help" ViewHelp
!ifdef VIEW_DOC
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like View the Documentation?" IDNO NoDoc
ExecShell "open" "$INSTDIR\${VIEW_DOC}"
NoDoc:
!endif
SectiOnEnd
;----------------------
;Descriptions used in components to install page (description Text Stings per Section
;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
; !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI)
;!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN STUFF HERE!
IfFileExists $WINDIR\Microsoft.NET\Framework\v2.0.50727\regasm.exe Found13 NoFound13
Found13:
execwait '$WINDIR\Microsoft.NET\Framework\v2.0.50727\regasm.exe /u "$INSTDIR\${ADDIN_DLL1}"'
NoFound13:
IfFileExists $WINDIR\Microsoft.NET\Framework64\v2.0.50727\regasm.exe Found14 NoFound14
Found14:
execwait '$WINDIR\Microsoft.NET\Framework64\v2.0.50727\regasm.exe /u "$INSTDIR\${ADDIN_DLL1}"'
NoFound14:
Sleep 1000
Delete "$INSTDIR\${ADDIN_DLL1}"
Delete "$INSTDIR\${File_1}"
Delete "$INSTDIR\${UNINST_EXE}"
!ifdef VIEW_DOC
Delete "$INSTDIR\${VIEW_DOC}"
!endif
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\${PRODUCT}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ADDIN_NAME}"
SectionEnd