Notifications
Clear all

[Closed] [How to] Detect most current installed max version for NSIS installer

After I’ve been searching around a while how to let your install script detect the most current max version, I finally made it
Since I didn’t find any satisfying resources, I’d like to share it with you in case you get into this “trouble”…
The script should check for version 2009, if not found 2008, if not found r9 and then pre-select the found dir in the “pick a dir” form.

Why create an installer anyway?
http://www.scriptspot.com/Tutorials/NSIS/Creation%20Application%20Installers%20for%20MaxScripts.htm

Hope somebody finds it useful

The NSI file:

;---------------------------------------------------------------------------------------------
  ; Meta data:
  ;---------------------------------------------------------------------------------------------
  ; Currently supported 3ds Max versions:
  ; 
[li] 3ds Max 2009 - 32bit[/li]  ; 
[li] 3ds Max 2008 - 32bit[/li]  ; 
[li] 3ds Max 9 SP2 - 32bit[/li]  !define APP_NAME "TYPE NAME HERE"
  Name "${APP_NAME}"
  OutFile "${APP_NAME}.exe"
  
  ;The path where 3ds Max is located:
  Var MAX_DIR 
  
  ;Page setup:
  Page custom getMAX_DIR
  Page instfiles
  
  ;---------------------------------------------------------------------------------------------
  ; Try to detect the most current version of 3ds Max and pre-set it in the form:
  ;---------------------------------------------------------------------------------------------
  Function ".onInit"
    InitPluginsDir
    File /oname=$PLUGINSDIR\uig_select_installdir.ini "uig_select_installdir.ini"
    ; Scan for possible REG-entries:
    MAX2009:
    ReadRegStr $MAX_DIR HKLM "SOFTWARE\Autodesk\3dsMax\11.0\MAX-1:409" "Installdir"
    StrCmp $MAX_DIR "" MAX2008 FOUND_MOST_CURRENT
  
    MAX2008:
    ReadRegStr $MAX_DIR HKLM "SOFTWARE\Autodesk\3dsMax\10.0\MAX-1:409" "Installdir"
    StrCmp $MAX_DIR "" MAX9 FOUND_MOST_CURRENT
  
    MAX9:
    ReadRegStr $MAX_DIR HKLM "SOFTWARE\Autodesk\3dsMax\9.0\MAX-1:409" "Installdir"
  
    FOUND_MOST_CURRENT:
    ; Write max dir into form:
    WriteINIStr "$PLUGINSDIR\uig_select_installdir.ini" "Field 3" "state" $MAX_DIR
  FunctionEnd
  
  Function getMAX_DIR
    Push $R0
    InstallOptions::dialog $PLUGINSDIR\uig_select_installdir.ini
    Pop $R0
    ReadINIStr $MAX_DIR "$PLUGINSDIR\uig_select_installdir.ini" "Field 3" "state"
    ;MessageBox MB_OK "$MAX_DIR"
    Pop $R0
  FunctionEnd
  
  ;---------------------------------------------------------------------------------------------
  ; The actual copying of the files:
  ;---------------------------------------------------------------------------------------------
  Section "Script files" SEC01
    SetOutPath "$MAX_DIR\Scripts\Startup"
    SetOverwrite ifnewer
    File "yourScript.ms"
    ;etc....
  SectionEnd

The INI file (form, referenced as uig_select_installdir.ini in the script above)

[Settings]
  NumFields=3
  
  [Field 1]
  Type=Groupbox
  Text=Install uMax
  Left=0
  Right=264
  Top=0
  Bottom=130
  
  [Field 2]
  Type=Label
  Text=Please locate your 3ds Max ROOT directory:
  Left=20
  Right=168
  Top=26
  Bottom=40
  
  [Field 3]
  Type=DirRequest
  State=test
  Left=22
  Right=220
  Top=68
  Bottom=80
  
2 Replies

That tutorial page could do with an update, for sure… I think I pasted this elsewhere, but here’s what I use for 3ds Max 4-2009:


ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\4.0\MAX-1:409" "uninstallpath"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\5.0\MAX-1:409" "uninstallpath"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\6.0" "Installdir"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\7.0" "Installdir"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\8.0" "Installdir"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\9.0\MAX-1:409" "Installdir"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\10.0\MAX-1:409" "Installdir"
ReadRegStr $DIR_INST HKLM "SOFTWARE\Autodesk\3DSMAX\11.0\MAX-1:409" "Installdir"

If you are installing scripts that require 64bit access (e.g. the script has a supporting (maxscript) plugin), don’t forget to set…

setRegView 64

…before accessing the registry.

Edit: holy whitespace, batman. Fixed

thanks for the setregview tip, it would have taken me ages to find that out