Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

Maxscript making a self installing mzp

Kingblue
polycounter lvl 8
Offline / Send Message
Kingblue polycounter lvl 8
I've made my first script. I've searched the help but really couldn't find a method to
declare folders, how to make my ms script a mzp self installing file and so on. The sources I've read say different things (for example the path to place the ms file in).
Any suggestion would really help me shed some light on the problem.

Replies

  • monster
    Offline / Send Message
    monster polycounter
    If it's just a single file I would just make it available for download.

    An MZP file is a zip file with the extension renamed. The easiest method I've found to use MZP files is to have it launch another maxscript and then let that finish the work. Inside the MZP file you should have a file named mzp.run with contents similar to this:
    1. name "My Tool"
    2. version 1.0
    3.  
    4. extract to $temp\mytool
    5.  
    6. run installer_mytool.ms
    7. drop installer_mytool.ms
    8.  
    9. clear temp on MAX exit

    The mzp.run file is capable of doing more operations, but I haven't had much success with that. That's why I just have it run another MaxScript. You can have installer_mytool.ms delete any previous verion, copy the script to the proper location, evaluate the file, and finally prompt that installation failed or was successful.
  • miauu
    Offline / Send Message
    miauu polycounter lvl 15
    Go here and dlownload RTTAssist_1.6.mzp
    Unzip the mzp in separate folder. You will find all files that monster mentoined. The install.ms uses some DOS commands and creates new folders, move the ms, mcr. and icon files etc.
    Also, you can download ToTex and take a look into his install.ms file - HiddenDOSCommand is used.
    Oitliner ver 2 have installe.ms that is use dotNet for createing folders.
    Get what is best for you and use it.
    :)

    P.S. you can use the mzp.run to create folders and move the files, but in Win Vista, Win7, you have to ruun the max and the MZP as adnimistrator.
  • Kingblue
    Offline / Send Message
    Kingblue polycounter lvl 8
    Ok, I'm starting to make some order in my mind. Here are the steps that I've traced so far.

    1. Put your script and icon files in a zip file and rename it to mzp.
    2. Write a text file with instructions to copy the folder contained in the mzp file to windows temp directory. You can't
    do it directly,you must delegate another ms.file (already stored in the mzp file). Save this as mzp.run
    Example

    name "John Doe"

    Version Beta

    extract to $temp/johndoe
    run "johndoeinstaller.ms"
    drop "johndoeinstaller.ms"

    clear temp


    3.Compile the delegate johndoeinstaller.ms file that shall do the installation operations like copying files and so on. Here I'm lost again.
    Can you suggest some info on this?
  • miauu
    Offline / Send Message
    miauu polycounter lvl 15
    Did you examine the code of the installers, that I mentioned above?
    For exampel RTTAssist installer:
    the mzp.run code
    1. name "RTTAssist"
    2. version 1.6
    3.  
    4. treeMove "tempRTTAssistFolder" to "$temp"
    5.  
    6. run "RTTAssistInstall.ms"
    7. drop "RTTAssistInstall.ms"
    8.  
    9. clear temp
    The RTTAssistInstall file that do the installation - copy files, create directories.
    1. --******************************************************************************************************
    2. -- Created: 12-06-2011
    3. -- Last Updated: 25-07-2011
    4. --
    5. -- Author : Kostadin Kotev / miau_u@yahoo.com /
    6. -- Version: 3ds max 2009 and up
    7. --
    8. -- Discription:
    9. -- RTTAssist Install file
    10. --******************************************************************************************************
    11. -- MODIFY THIS AT YOUR OWN RISK
    12.  
    13. (
    14. global RTTAssist_Instalation
    15. try ( destroyDialog RTTAssist_Instalation ) catch ()
    16. try ( destroyDialog miauuRTTassist ) catch ()
    17. rollout RTTAssist_Instalation "RTTAssist 1.6 Setup"
    18. (
    19. local tempRTTAssistFolder = pathConfig.GetDir #temp+"\\tempRTTAssistFolder"
    20. local usRTTAui = pathConfig.GetDir #userscripts+"\\RTTAssistUI"
    21. local usRTTAuiIco = pathConfig.GetDir #userscripts+"\\RTTAssistUI\\RTTAssistIcons"
    22. local usRTTAuiPrst01 = pathConfig.GetDir #userscripts + "\\RTTAssist"
    23. local usRTTAuiPrst02 = pathConfig.GetDir #userscripts + "\\RTTAssist\\Presets"
    24. ImgTag ImgTag_BG bitmap:(bitmap 2 2 color:gray) pos:[0,0] \
    25. width:309 height:194 opacity:1 transparent:(color 0 255 255) enabled:off
    26.  
    27. hyperLink httpOficialSite "Oficial Site" pos:[213,138] color:(color 176 208 231) hoverColor:(color 82 129 181) visitedColor:(color 65 81 100) address:"http://vertexbee.com/rttassist.htm"
    28. hyperLink httpVideos "Videos" pos:[213,152] color:(color 176 208 231) hoverColor:(color 82 129 181) visitedColor:(color 65 81 100) address:"http://www.youtube.com/user/RTTassist?feature=mexp"
    29. ImgTag it_License bitmap:(bitmap 2 2 color:white) pos:[213,166] \
    30. width:36 height:9 opacity:1 transparent:(color 0 255 255)
    31. button btn_Install "Install" width:138 height:30 pos:[30,103]
    32. button btn_Uninstall "Uninstall" width:138 height:30 pos:[30,145]
    33.  
    34. function DeleteDirAndSubDir rootDir =
    35. (
    36. try ( DOSCommand ("rmDir \"" + rootDir + "\" /s /q") ) catch (messagebox "Can't delete RTTAssist folders!" title:"RTTAssist Install Error!!!")
    37. )
    38. function DeleteFiles curDir file =
    39. (
    40. filesToDelete = getFiles (curDir + file)
    41. for f in filesToDelete do deleteFile f
    42. )
    43. function ValidateDirectory _dirNameIn =
    44. (
    45. local _dirName = copy _dirNameIn
    46. local c
    47. for i = _dirName.count to 1 by -1 while (c=_dirName[i]; c=="\\" or c== "/") do
    48. _dirName = subString _dirName 1 (i-1)
    49. if doesFileExist _dirName then
    50. dirExists = true
    51. else
    52. dirExists = false
    53. return dirExists
    54. )
    55. function InstalRTTAssist =
    56. (
    57. if tempRTTAssistFolder != "" then
    58. (
    59. -- create main, icons and preset folders
    60. local rttAssistMainFolder = (makeDir usRTTAui)
    61. local iconFolder = (makeDir usRTTAuiIco)
    62. local presetFolder01 = (makeDir usRTTAuiPrst01)
    63. local presetFolder02 = (makeDir usRTTAuiPrst02)
    64. if presetFolder02 != true then
    65. (
    66. messagebox "Unable to create \"Preset\" folder" title:"RTTAssist Installation Error!!!"
    67. )
    68. else
    69. (
    70. -- copy icons and UI files
    71. if iconFolder == true then
    72. (
    73. allPreinstPNGfiles = (getFiles (tempRTTAssistFolder+"\\RTTAssistUI\\RTTAssistIcons\\*.png"))
    74. for pngFile in allPreinstPNGfiles do
    75. (
    76. copyFile pngFile (usRTTAui+"\\RTTAssistIcons\\"+filenameFromPath pngFile)
    77. )
    78. allInstalledPNGfiles = (getFiles (usRTTAui+"\\RTTAssistIcons\\*.png"))
    79. if allInstalledPNGfiles.count != allPreinstPNGfiles.count do messagebox "Installation Error!!!" title:"RTTAsssist"
    80. )
    81. else
    82. messagebox "Unable to create \"RTTAssist Icons\" folder" title:"RTTAssist Installation Error!!!"
    83. -- copy htm, ini, license and ms files
    84. if rttAssistMainFolder == true then
    85. (
    86. allPreinstMCIfiles = (getFiles (tempRTTAssistFolder+"\\RTTAssistUI\\*.*"))
    87. for mciFile in allPreinstMCIfiles do
    88. (
    89. copyFile mciFile (usRTTAui+"\\"+filenameFromPath mciFile)
    90. )
    91. allInstalledMCIfiles = (getFiles (usRTTAui+"\\*.*"))
    92. if allInstalledMCIfiles.count != allPreinstMCIfiles.count do messagebox "Installation Error!!!" title:"RTTAsssist"
    93. )
    94. else
    95. messagebox "Unable to create main \"RTTAssist\" folder" title:"RTTAssist Installation Error!!!"
    96. -- copy toolbar Icons
    97. for tBarIcoFiles in (getFiles (tempRTTAssistFolder+"\\icons\\*.*")) do
    98. (
    99. copyFile tBarIcoFiles (pathConfig.GetDir #userIcons+"\\"+filenameFromPath tBarIcoFiles)
    100. )
    101. -- copy RTTAssist macro
    102. if (copyFile (tempRTTAssistFolder+"\\Macro_RTTAssist.mcr") (usRTTAui+"\\Macro_RTTAssist.mcr")) then
    103. ( -- load macro
    104. fileIn (usRTTAui+"\\Macro_RTTAssist.mcr")
    105. -- start RTTAssist
    106. try(fileIn (usRTTAui+"\\RTTAssist.ms"))
    107. catch(messagebox "Please, start RTTAssist manualy!" title:"RTTAssist")
    108. )
    109. else
    110. messagebox "Can't copy the macro file of RTTAssist!" title:"RTTAssist Installation Error!!!"
    111. )
    112. )
    113. else
    114. messagebox "Insallation Error!!!" title:"RTTAsssist"
    115. )
    116. on RTTAssist_Instalation open do
    117. (
    118. if tempRTTAssistFolder != "" then
    119. (
    120. ImgTag_BG.bitmap = (openBitmap (tempRTTAssistFolder+"\\RTTAssistInstallBG.png"))
    121. it_License.bitmap = (openBitmap (tempRTTAssistFolder+"\\miauuITlicense.png"))
    122. )
    123. if onlineUpdate == true do
    124. (
    125. if (doesFileExist ((getDir #userscripts) + "\RTTAssistUI\RTTAssist.ms")) do
    126. (
    127. DeleteFiles ((getDir #userscripts) + "\RTTAssistUI") "*.*" -- delete the ms, ini and help file
    128. DeleteFiles ((getDir #userscripts) + "RTTAssistIcons") "*.*" -- delete the icons
    129. DeleteDirAndSubDir ((getDir #userscripts) + "\RTTAssistUI") -- delete folders
    130. DeleteFiles (getDir #userMacros) "*RTTAssist*.*" -- delete macro
    131. DeleteFiles ("$max\\ui\\macroscripts\\") "Macro_RTTAssist.mcr"
    132. )
    133. InstalRTTAssist()
    134. destroydialog RTTAssist_Instalation
    135. )
    136. )
    137. on it_License lbuttondown do
    138. (
    139. licFile = tempRTTAssistFolder+"\license.html"
    140. shelllaunch licFile ""
    141. )
    142. on it_License mouseover do
    143. (
    144. it_License.bitmap = (openBitmap (tempRTTAssistFolder+"\\miauuITlicenseHover.png"))
    145. )
    146. on it_License mouseout do
    147. (
    148. it_License.bitmap = (openBitmap (tempRTTAssistFolder+"\\miauuITlicense.png"))
    149. )
    150. on RTTAssist_Instalation close do
    151. (
    152. if tempRTTAssistFolder != "" then
    153. DeleteDirAndSubDir tempRTTAssistFolder
    154. )
    155. on btn_Install pressed do
    156. (
    157. if tempRTTAssistFolder != "" then
    158. (
    159. -- create RTTAssistUI directory
    160. if (ValidateDirectory usRTTAui) == false then
    161. (-- if RTTAssistUI folder does not exist start new installation
    162. InstalRTTAssist()
    163. destroydialog RTTAssist_Instalation
    164. )
    165. else
    166. (-- if RTTAssistUI folder exist show upgrade dialog
    167. try(destroyDialog ReinstallUpgrade)catch()
    168. rollout ReinstallUpgrade "RTTAssist 1.6"
    169. (
    170. label lb1 "RTTassist has already been installed!" pos:[20,20]
    171. label lb2 "To reinstall or update RTTAssist press \"Continue\"." pos:[20,40]
    172. label lb "To cancel the operation press \"Cancel\"." pos:[20,60]
    173. button btn_Continue "Continue" pos:[150,90] width:50
    174. button btn_Cancel "Cancel" pos:[210,90] width:50
    175. on btn_Continue pressed do
    176. (
    177. if (doesFileExist ((getDir #userscripts) + "\RTTAssistUI\RTTAssist.ms")) or \
    178. (doesFileExist ((getDir #userscripts) + "\RTTAssistUI\RTTAssist.mse")) do
    179. (
    180. DeleteFiles ((getDir #userscripts) + "\RTTAssistUI") "*.*" -- delete the ms, ini and help file
    181. DeleteFiles ((getDir #userscripts) + "\RTTAssistIcons") "*.*" -- delete the icons
    182. DeleteDirAndSubDir ((getDir #userscripts) + "\RTTAssistUI") -- delete folders
    183. DeleteFiles ((getDir #userMacros) + "\\") "*RTTAssist*.*" -- delete macro
    184. DeleteFiles ("$max\\ui\\macroscripts\\") "Macro_RTTAssist.mcr"
    185. )
    186. InstalRTTAssist()
    187. destroydialog ReinstallUpgrade
    188. destroydialog RTTAssist_Instalation
    189. )
    190. on btn_Cancel pressed do
    191. (
    192. destroydialog ReinstallUpgrade
    193. )
    194. )
    195. createdialog ReinstallUpgrade height:120 width:275 bgcolor:white fgcolor:red modal:true
    196. )
    197. )
    198. else
    199. messagebox "Insallation Error!!!" title:"RTTAsssist"
    200. )
    201. on btn_Uninstall pressed do
    202. (
    203. if (doesFileExist ((getDir #userscripts) + "\RTTAssistUI\RTTAssist.ms")) or \
    204. (doesFileExist ((getDir #userscripts) + "\RTTAssistUI\RTTAssist.mse")) do
    205. (
    206. DeleteFiles ((getDir #userscripts) + "\RTTAssistUI") "*.*" -- delete the ms, ini and help file
    207. DeleteFiles ((getDir #userscripts) + "\RTTAssistIcons") "*.*" -- delete the icons
    208. DeleteDirAndSubDir ((getDir #userscripts) + "\RTTAssistUI") -- delete folders
    209. DeleteFiles ((getDir #userscripts) + "\RTTAssist\Presets") "*.*" -- delete the rpf and rps file
    210. DeleteDirAndSubDir ((getDir #userscripts) + "\RTTAssist") -- delete folders
    211. DeleteFiles ((getDir #userMacros) + "\\") "*RTTAssist*.*" -- delete macro
    212. DeleteFiles ("$max\\ui\\macroscripts\\") "Macro_RTTAssist.mcr"
    213. -- delete tempRTTAssistfolder
    214. if (tempRTTAssistFolder != "") then
    215. DeleteDirAndSubDir tempRTTAssistFolder
    216. destroydialog RTTAssist_Instalation
    217. rollout UninstallComplete "RTTAssist 1.6 Setup"
    218. (
    219. label lb1 " Uninstallation complete." pos:[20,20]
    220. label lb2 "Thank you for using RTTAssist." pos:[20,40]
    221. )
    222. createdialog UninstallComplete height:70 width:185 bgcolor:white fgcolor:black
    223. )
    224. )
    225. )
    226. createDialog RTTAssist_Instalation height:194 width:309 bgcolor:gray
    227. )
    This installer uses some DOS commands
    The Totex installer uses HiddenDosCommand
    The Outliner installer uses dotnet
    Just check the codes and use what is best for you
    :)
  • Kingblue
    Offline / Send Message
    Kingblue polycounter lvl 8
    I didn't think that copy and pasting files in Mxs was harder than making the script itself (being said that's my first script). Whew, I'll start deciphering it. Thanks
  • monster
    Offline / Send Message
    monster polycounter
    Once you're an old pro like us, you'll have a build.ms that creates the mzp for you. :)
  • miauu
    Offline / Send Message
    miauu polycounter lvl 15
    Go here and check of this tool will help you to create the mzp with less efforts
  • Kingblue
    Offline / Send Message
    Kingblue polycounter lvl 8
    Thanks again, guys.
Sign In or Register to comment.