Skip to content
⌘ NSIS Forum Archive

About creating installer for maxscript(in 3ds max)

1 posts

aldrick#

About creating installer for maxscript(in 3ds max)

Jeff hannah wrote a great doc about this.And using wizard you can build most of this installer.But there issues.

1.When using codes to detect 3ds max version and directory in windows registry,I am not sure where to put these codes:
ReadRegStr $TempPath HKCR "3dsmax\DefaultIcon\" ""
StrCpy $INSTDIR $TempDir -30
,which are to get this registry key and assign it to a NSIS value.But,where should I put these lines.

2.That's the same situation with detecting whether 3ds max is running and suggest users to close it if it is running.Below are scripts that Hannah suggests:
Push $9
loop:
found
FindWindow $9 "3dsmax"
IntCmp $9 0 installMaxFiles
MessageBox MB_YESNO ‘Max is running. Close it?’ IDYES closeMax IDNO done
Sleep 1000
Goto loop
closeMax:
SendMessage $9 ${WM_CLOSE} 0 0
Sleep 1000
IfErrors done installMaxFiles
installMaxFiles:
<File installation lines go here>
Done:
Pop $9
I am not sure where to put them.

Please give me some elaborations,thanks a lot!

My project script is like this(runs good):


; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "My application"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "My company, Inc."
!define PRODUCT_WEB_SITE "http://www.mycompany.com"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "DensityToolSetup.exe"
InstallDir "$INSTDIR"
ShowInstDetails show
ShowUnInstDetails show

Section "denstiyTools" SEC01

SetOutPath "$INSTDIR\scripts"
SetOverwrite ifnewer
File "D:\tutorial\MAXScript\Creating Installers for MAXScripts\dcctools\unarranged\DensityTool\Scripts\DensityTool_standalone.ms"
SetOutPath "$INSTDIR\ui\macroscripts"
File "D:\tutorial\MAXScript\Creating Installers for MAXScripts\dcctools\unarranged\DensityTool\ui\macroscripts\DensityTool.mcr"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} ""
!insertmacro MUI_FUNCTION_DESCRIPTION_END


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\ui\macroscripts\DensityTool.mcr"
Delete "$INSTDIR\scripts\DensityTool_standalone.ms"

RMDir "$INSTDIR\ui\macroscripts"
RMDir "$INSTDIR\scripts"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
Just want to know where should I add the directory registry key variable and statements and the if-the-program-is-already-running detecting scripts into the main projects.

BTW,I am using HM NIS EDIT.