Advertisement
QuantumWarpCode

First NSIS Installer for GameMaker

Jul 19th, 2014
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;--------------------------------
  2. !include MUI2.nsh
  3.  
  4. !ifndef FULL_VERSION
  5. !define FULL_VERSION      "1.1.7.1"
  6. !endif
  7.  
  8. !ifndef SOURCE_DIR
  9. !define SOURCE_DIR        "C:\source\temp\InstallerTest\runner"
  10. !endif
  11.  
  12. !ifndef INSTALLER_FILENAME
  13. !define INSTALLER_FILENAME    "C:\source\temp\InstallerTest\RunnerInstaller.exe"
  14. !endif
  15.  
  16. !ifndef MAKENSIS
  17. !define MAKENSIS          "%appdata%\GameMaker-Studio\makensis"
  18. !endif
  19.  
  20. !ifndef COMPANY_NAME
  21. !define COMPANY_NAME      ""
  22. !endif
  23.  
  24. !ifndef COPYRIGHT_TXT
  25. !define COPYRIGHT_TXT     "(c)Copyright 2014"
  26. !endif
  27.  
  28. !ifndef FILE_DESC
  29. !define FILE_DESC         "Created with GameMaker:Studio"
  30. !endif
  31.  
  32. !ifndef LICENSE_NAME
  33. !define LICENSE_NAME      "License.txt"
  34. !endif
  35.  
  36. !ifndef README_NAME
  37. !define README_NAME      "Readme.txt"
  38. !endif
  39.  
  40. !ifndef ICON_FILE
  41. !define ICON_FILE       "icon.ico"
  42. !endif
  43.  
  44. !ifndef IMAGE_FINISHED
  45. !define IMAGE_FINISHED      "Runner_finish.bmp"
  46. !endif
  47.  
  48. !ifndef IMAGE_HEADER
  49. !define IMAGE_HEADER      "Runner_header.bmp"
  50. !endif
  51.  
  52. !ifndef PRODUCT_NAME
  53. !define PRODUCT_NAME      "Sorry"
  54. !endif
  55.  
  56. !define APP_NAME        "${PRODUCT_NAME}"
  57. !define SHORT_NAME        "${PRODUCT_NAME}"
  58.  
  59. ;;USAGE:
  60. !define MIN_FRA_MAJOR "2"
  61. !define MIN_FRA_MINOR "0"
  62. !define MIN_FRA_BUILD "*"
  63.  
  64. !addplugindir   "."
  65.  
  66. ;--------------------------------
  67.  
  68. ; The name of the installer
  69. Name "${APP_NAME}"
  70. Caption "${APP_NAME}"
  71. BrandingText "${APP_NAME}"
  72.  
  73. ; The file to write
  74. OutFile "${INSTALLER_FILENAME}"
  75.  
  76. ; The default installation directory
  77. InstallDir "C:\Program Files\${APP_NAME}"
  78.  
  79. ; Registry key to check for directory (so if you install again, it will
  80. ; overwrite the old one automatically)
  81. InstallDirRegKey HKCU "Sorry" "Install_Dir"
  82.  
  83. ; Request application privileges for Windows Vista
  84. RequestExecutionLevel user
  85.  
  86.  
  87. VIProductVersion "${FULL_VERSION}"
  88. VIAddVersionKey /LANG=1033 "FileVersion" "${FULL_VERSION}"
  89. VIAddVersionKey /LANG=1033 "ProductVersion" "${FULL_VERSION}"
  90. VIAddVersionKey /LANG=1033 "ProductName" "${PRODUCT_NAME}"
  91. VIAddVersionKey /LANG=1033 "CompanyName" "${PRODUCT_PUBLISHER}"
  92. VIAddVersionKey /LANG=1033 "LegalCopyright" "${COPYRIGHT_TXT}"
  93. VIAddVersionKey /LANG=1033 "FileDescription" "${FILE_DESC}"
  94.  
  95.  
  96.  
  97. !define MUI_HEADERIMAGE
  98. !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
  99. !define MUI_ICON            "${ICON_FILE}"
  100. !define MUI_WELCOMEFINISHPAGE_BITMAP  "${IMAGE_FINISHED}"
  101. !define MUI_HEADERIMAGE_BITMAP      "${IMAGE_HEADER}"
  102. !define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH
  103.  
  104. RequestExecutionLevel admin
  105.  
  106. ;--------------------------------
  107.  
  108. ; Pages
  109. !insertmacro MUI_PAGE_LICENSE "${LICENSE_NAME}"
  110. !insertmacro MUI_PAGE_COMPONENTS
  111. !insertmacro MUI_PAGE_DIRECTORY
  112. !insertmacro MUI_PAGE_INSTFILES
  113.     # These indented statements modify settings for MUI_PAGE_FINISH
  114.     !define MUI_FINISHPAGE_NOAUTOCLOSE
  115.     !define MUI_FINISHPAGE_RUN_TEXT "Start ${PRODUCT_NAME}"
  116.     !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_NAME}.exe"
  117. !insertmacro MUI_PAGE_FINISH
  118.  
  119. Var DirectXSetupError
  120.  
  121. UninstPage uninstConfirm
  122. UninstPage instfiles
  123.  
  124. !insertmacro MUI_LANGUAGE "English"
  125. ;--------------------------------
  126.  
  127. ; The stuff to install
  128. Section `${APP_NAME}`
  129.   SectionIn RO
  130.  
  131.   ; Set output path to the installation directory.
  132.   SetOutPath $INSTDIR
  133.  
  134.   ; Put file there
  135.   File "${LICENSE_NAME}"
  136.   File /r "${SOURCE_DIR}\*.*"
  137.   File "${README_NAME}"
  138.  
  139.   ; Write the uninstall keys for Windows
  140.   WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "DisplayName" "${APP_NAME}"
  141.   WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  142.   WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "NoModify" 1
  143.   WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}" "NoRepair" 1
  144.   WriteUninstaller "uninstall.exe"
  145.  
  146. SectionEnd
  147.  
  148. ; Optional section (can be disabled by the user)
  149. Section "Start Menu Shortcuts"
  150.  
  151.   CreateDirectory "$SMPROGRAMS\${APP_NAME}"
  152.   CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  153.   CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "$INSTDIR\${PRODUCT_NAME}.exe"
  154.   CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME} License.lnk" "notepad.exe" "$INSTDIR\License.txt"
  155.   CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME} Readme.lnk" "notepad.exe" "$INSTDIR\Readme.txt"
  156.  
  157. SectionEnd
  158.  
  159.  
  160. ; Optional section (can be enabled by the user)
  161. Section /o "Desktop shortcut"
  162.  
  163.   CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" ""
  164.  
  165. SectionEnd
  166.  
  167.  
  168. ;--------------------------------
  169.  
  170. ; Uninstaller
  171.  
  172. Section "Uninstall"
  173.   ; Remove registry keys
  174.   DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SHORT_NAME}"
  175.  
  176.   ; Remove files and uninstaller (everything)
  177.   RMDir /r "$INSTDIR"
  178.  
  179.   ; Remove desktop icon
  180.   Delete "$DESKTOP\${APP_NAME}.lnk"
  181.  
  182.   ; Remove shortcuts, if any
  183.   Delete "$SMPROGRAMS\${APP_NAME}\*.*"
  184.  
  185.   ; Remove directories used
  186.   RMDir "$SMPROGRAMS\${APP_NAME}"
  187.   RMDir "$INSTDIR"
  188.  
  189. SectionEnd
  190.  
  191.  
  192. ;--------------------------------
  193. ;
  194. ; This should be the LAST section available....
  195. ;
  196. Section "DirectX Install" SEC_DIRECTX
  197.  
  198.  SectionIn RO
  199.  
  200.  SetOutPath "$TEMP"
  201.  File "${MAKENSIS}\dxwebsetup.exe"
  202.  DetailPrint "Running DirectX Setup..."
  203.  ExecWait '"$TEMP\dxwebsetup.exe" /Q' $DirectXSetupError
  204.  DetailPrint "Finished DirectX Setup"
  205.  
  206.  Delete "$TEMP\dxwebsetup.exe"
  207.  
  208.  SetOutPath "$INSTDIR"
  209.  
  210. SectionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement