Custom.nsh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. ${SegmentFile}
  2. ;=== START INTEGRITY CHECK 1.1 Var
  3. Var bolCustomIntegrityCheckStartUnsupported
  4. Var strCustomIntegrityCheckVersion
  5. ;=== END INTEGRITY CHECK
  6. !include WinMessages.nsh
  7. ${Segment.OnInit}
  8. ;=== START INTEGRITY CHECK 1.1 OnInit
  9. ;Check for improper install/upgrade without running the PA.c Installer which can cause issues
  10. ;Designed to not require ReadINIStrWithDefault which is not included in the PA.c Launcher code
  11. ${If} ${FileExists} "$EXEDIR\App\AppInfo\appinfo.ini"
  12. ${If} ${FileExists} "$EXEDIR\App\AppInfo\pac_installer_log.ini"
  13. ReadINIStr $R0 "$EXEDIR\App\AppInfo\pac_installer_log.ini" "PortableApps.comInstaller" "Info2"
  14. ${If} $R0 == "This file was generated by the PortableApps.com Installer wizard and modified by the official PortableApps.com Installer TM Rare Ideas, LLC as the app was installed."
  15. StrCpy $R1 "true"
  16. ${Else}
  17. StrCpy $R1 "false"
  18. ${EndIf}
  19. ${Else}
  20. StrCpy $R1 "false"
  21. ${EndIf}
  22. ${Else}
  23. StrCpy $R1 "true"
  24. ${EndIf}
  25. ${If} $R1 == "false"
  26. ;Upgrade or install sans the PortableApps.com Installer which can cause compatibility issues
  27. ClearErrors
  28. ReadINIStr $0 "$EXEDIR\App\AppInfo\appinfo.ini" "Version" "PackageVersion"
  29. ${If} ${Errors}
  30. ${OrIf} $0 == ""
  31. StrCpy $0 "0.0.0.1"
  32. ClearErrors
  33. ${EndIf}
  34. ClearErrors
  35. ReadINIStr $1 "$EXEDIR\Data\settings\${AppID}Settings.ini" "${AppID}Settings" "InvalidPackageWarningShown"
  36. ${If} ${Errors}
  37. ${OrIf} $1 == ""
  38. StrCpy $1 "0.0.0.0"
  39. ClearErrors
  40. ${EndIf}
  41. ${VersionCompare} $0 $1 $2
  42. ${If} $2 == 1
  43. MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 `Integrity Failure Warning: ${NamePortable} was installed or upgraded without using its installer and some critical files may have been modified. This could cause data loss, personal data left behind on a shared PC, functionality issues, and/or may be a violation of the application's license. Neither the application publisher nor PortableApps.com will be responsible for any issues you encounter.$\r$\n$\r$\nWould you like to start ${NamePortable} in its current unsupported state?` IDYES CustomIntegrityCheckGotoStartAnyway IDNO CustomIntegrityCheckGotoDownloadQuestion
  44. CustomIntegrityCheckGotoDownloadQuestion:
  45. ;Check to ensure we have a valid homepage before asking the user
  46. StrCpy $R0 ""
  47. ${If} ${FileExists} "$EXEDIR\App\AppInfo\appinfo.ini"
  48. ReadINIStr $R0 "$EXEDIR\App\AppInfo\appinfo.ini" "Details" "Homepage"
  49. ${EndIf}
  50. ${If} $R0 == ""
  51. Abort
  52. ${Else}
  53. StrCpy $R1 $R0 4
  54. ${If} $R1 != "http"
  55. ${AndIf} $R1 != "HTTP"
  56. StrCpy $R0 "http://$R0"
  57. ${EndIf}
  58. ${EndIf}
  59. MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON1 `Would you like to visit the ${NamePortable} homepage to download the app and upgrade your current install?` IDYES CustomIntegrityCheckGotoURL IDNO CustomIntegrityCheckGotoAbort
  60. CustomIntegrityCheckGotoURL:
  61. ExecShell "open" $R0
  62. Abort
  63. CustomIntegrityCheckGotoAbort:
  64. Abort
  65. CustomIntegrityCheckGotoStartAnyway:
  66. StrCpy $bolCustomIntegrityCheckStartUnsupported true
  67. StrCpy $strCustomIntegrityCheckVersion $0
  68. ${EndIf}
  69. ${EndIf}
  70. ;=== END INTEGRITY CHECK
  71. !macroend
  72. ${SegmentInit}
  73. ;Ensure we have a proper Documents path
  74. ExpandEnvStrings $1 "%PortableApps.comDocuments%"
  75. ${If} $1 == ""
  76. ${OrIfNot} ${FileExists} "$1\*.*"
  77. ${GetParent} $EXEDIR $3
  78. ${GetParent} $3 $1
  79. ${If} $1 == "" ;Be sure we didn't just GetParent on Root
  80. StrCpy $1 $3
  81. ${EndIf}
  82. ${If} ${FileExists} "$1\Documents\*.*"
  83. StrCpy $2 "$1\Documents"
  84. ${Else}
  85. ${GetRoot} $EXEDIR $1
  86. ${If} ${FileExists} "$1\Documents\*.*"
  87. StrCpy $2 "$1\Documents"
  88. ${Else}
  89. StrCpy $2 "$1"
  90. ${EndIf}
  91. ${EndIf}
  92. System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("PortableApps.comDocuments", "$2").r0'
  93. ${EndIf}
  94. !macroend
  95. ${SegmentPre}
  96. ReadEnvStr $0 "JAVA_HOME"
  97. ${WordReplace} $0 "\" "/" "+" $1
  98. System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("JAVA_HOME_FORWARDSLASH", "$1").r0'
  99. !macroend
  100. ${SegmentPrePrimary}
  101. ;=== START INTEGRITY CHECK 1.1 PrePrimary
  102. ${If} $bolCustomIntegrityCheckStartUnsupported == true
  103. WriteINIStr "$EXEDIR\Data\settings\${AppID}Settings.ini" "${AppID}Settings" "InvalidPackageWarningShown" $strCustomIntegrityCheckVersion
  104. ${EndIf}
  105. ;=== END INTEGRITY CHECK
  106. ;Load app ttf fonts
  107. FindFirst $0 $1 "$EXEDIR\App\fonts\*.ttf"
  108. ${DoWhile} $1 != ""
  109. System::Call "gdi32::AddFontResource(t'$EXEDIR\App\fonts\$1')i .r2"
  110. FindNext $0 $1
  111. ${Loop}
  112. FindClose $0
  113. ;Load app otf fonts
  114. FindFirst $0 $1 "$EXEDIR\App\fonts\*.otf"
  115. ${DoWhile} $1 != ""
  116. System::Call "gdi32::AddFontResource(t'$EXEDIR\App\fonts\$1')i .r2"
  117. FindNext $0 $1
  118. ${Loop}
  119. FindClose $0
  120. ;Load user ttf fonts
  121. FindFirst $0 $1 "$EXEDIR\Data\fonts\*.ttf"
  122. ${DoWhile} $1 != ""
  123. System::Call "gdi32::AddFontResource(t'$EXEDIR\Data\fonts\$1')i .r2"
  124. FindNext $0 $1
  125. ${Loop}
  126. FindClose $0
  127. ;Load user otf fonts
  128. FindFirst $0 $1 "$EXEDIR\Data\fonts\*.otf"
  129. ${DoWhile} $1 != ""
  130. System::Call "gdi32::AddFontResource(t'$EXEDIR\Data\fonts\$1')i .r2"
  131. FindNext $0 $1
  132. ${Loop}
  133. FindClose $0
  134. ;Let all running apps know
  135. SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=1
  136. !macroend
  137. ${SegmentPostPrimary}
  138. ;Remove app ttf fonts
  139. FindFirst $0 $1 "$EXEDIR\App\fonts\*.ttf"
  140. ${DoWhile} $1 != ""
  141. System::Call "gdi32::RemoveFontResource(t'$EXEDIR\App\fonts\$1')i .r2"
  142. FindNext $0 $1
  143. ${Loop}
  144. FindClose $0
  145. ;Remove app otf fonts
  146. FindFirst $0 $1 "$EXEDIR\App\fonts\*.otf"
  147. ${DoWhile} $1 != ""
  148. System::Call "gdi32::RemoveFontResource(t'$EXEDIR\App\fonts\$1')i .r2"
  149. FindNext $0 $1
  150. ${Loop}
  151. FindClose $0
  152. ;Remove user ttf fonts
  153. FindFirst $0 $1 "$EXEDIR\Data\fonts\*.ttf"
  154. ${DoWhile} $1 != ""
  155. System::Call "gdi32::RemoveFontResource(t'$EXEDIR\Data\fonts\$1')i .r2"
  156. FindNext $0 $1
  157. ${Loop}
  158. FindClose $0
  159. ;Remove user otf fonts
  160. FindFirst $0 $1 "$EXEDIR\Data\fonts\*.otf"
  161. ${DoWhile} $1 != ""
  162. System::Call "gdi32::RemoveFontResource(t'$EXEDIR\Data\fonts\$1')i .r2"
  163. FindNext $0 $1
  164. ${Loop}
  165. FindClose $0
  166. ;Let all running apps know
  167. SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=1
  168. !macroend