ssh-handler.nsi 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ; SSH Handler
  2. ;
  3. ; Douglas Thrift
  4. ;
  5. ; ssh-handler.nsi
  6. # Copyright 2013 Douglas Thrift
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http://www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. !ifndef SSH_HANDLER_VERSION
  20. !define SSH_HANDLER_VERSION "1.1.0.0"
  21. !endif
  22. !ifndef SSH_HANDLER_CONFIGURATION
  23. !define SSH_HANDLER_CONFIGURATION "Release"
  24. !endif
  25. !define SSH_HANDLER_NAME "SSH Handler"
  26. !define SSH_HANDLER_AUTHOR "Douglas Thrift"
  27. Name "${SSH_HANDLER_NAME}"
  28. OutFile "ssh-handler-${SSH_HANDLER_VERSION}.exe"
  29. SetCompressor /SOLID lzma
  30. ShowInstDetails show
  31. ShowUninstDetails show
  32. XPStyle on
  33. VIProductVersion "${SSH_HANDLER_VERSION}"
  34. VIAddVersionKey "ProductName" "${SSH_HANDLER_NAME}"
  35. VIAddVersionKey "CompanyName" "${SSH_HANDLER_AUTHOR}"
  36. VIAddVersionKey "LegalCopyright" "Copyright 2013 ${SSH_HANDLER_AUTHOR}"
  37. VIAddVersionKey "FileDescription" "${SSH_HANDLER_NAME}"
  38. VIAddVersionKey "FileVersion" "${SSH_HANDLER_VERSION}.0"
  39. VIAddVersionKey "ProductVersion" "${SSH_HANDLER_VERSION}.0"
  40. !define SSH_HANDLER "${SSH_HANDLER_NAME} ${SSH_HANDLER_VERSION}"
  41. !define SSH_HANDLER_EXE "ssh-handler.exe"
  42. !define SSH_HANDLER_SETTINGS_LNK "${SSH_HANDLER_NAME} Settings.lnk"
  43. !define SSH_HANDLER_USER_SETTINGS_LNK "${SSH_HANDLER_NAME} User Settings.lnk"
  44. !define SSH_HANDLER_GLOBAL_SETTINGS_LNK "${SSH_HANDLER_NAME} Global Settings.lnk"
  45. !define SWC_INPUT_TOOLKIT_DLL "System.Windows.Controls.Input.Toolkit.dll"
  46. !define SWC_LAYOUT_TOOLKIT_DLL "System.Windows.Controls.Layout.Toolkit.dll"
  47. !define WPF_TOOLKIT_DLL "WPFToolkit.dll"
  48. !define DOT_NET_FRAMEWORK_EXE "dotNetFx40_Client_setup.exe"
  49. !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
  50. !define UNINST_EXE "ssh-handler-uninst.exe"
  51. !define MULTIUSER_EXECUTIONLEVEL "Highest"
  52. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  53. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINST_REG}"
  54. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "UninstallString"
  55. !define MULTIUSER_INSTALLMODE_INSTDIR "${SSH_HANDLER_NAME}"
  56. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${UNINST_REG}"
  57. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallLocation"
  58. !define MULTIUSER_MUI
  59. !include "MultiUser.nsh"
  60. !include "MUI2.nsh"
  61. !include "FileFunc.nsh"
  62. !define MUI_COMPONENTSPAGE_NODESC
  63. !define MUI_FINISHPAGE_NOAUTOCLOSE
  64. !define MUI_FINISHPAGE_SHOWREADME "https://github.com/douglaswth/ssh-handler/blob/${SSH_HANDLER_VERSION}/README.md"
  65. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  66. !insertmacro MUI_PAGE_WELCOME
  67. !insertmacro MUI_PAGE_LICENSE LICENSE
  68. !insertmacro MUI_PAGE_COMPONENTS
  69. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  70. !insertmacro MUI_PAGE_DIRECTORY
  71. !insertmacro MUI_PAGE_INSTFILES
  72. !insertmacro MUI_PAGE_FINISH
  73. !define MUI_UNFINISHPAGE_NOAUTOCLOSE
  74. !insertmacro MUI_UNPAGE_WELCOME
  75. !insertmacro MUI_UNPAGE_CONFIRM
  76. !insertmacro MUI_UNPAGE_INSTFILES
  77. !insertmacro MUI_UNPAGE_FINISH
  78. !insertmacro MUI_LANGUAGE "English"
  79. !macro REGISTRY BASE_KEY
  80. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "" "URL:SSH Protocol"
  81. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "URL Protocol" ""
  82. WriteRegStr ${BASE_KEY} "Software\Classes\ssh\shell\open\command" "" '"$INSTDIR\${SSH_HANDLER_EXE}" "%1"'
  83. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayName" "$(^Name)"
  84. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayVersion" "${SSH_HANDLER_VERSION}"
  85. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "EstimatedSize" $0
  86. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "Publisher" "${SSH_HANDLER_AUTHOR}"
  87. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}"
  88. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "InstallLocation" "$INSTDIR"
  89. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoModify" 1
  90. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoRepair" 1
  91. !macroend
  92. !macro UN_REGISTRY BASE_KEY
  93. DeleteRegKey ${BASE_KEY} "Software\Classes\ssh"
  94. DeleteRegKey ${BASE_KEY} "${UNINST_REG}"
  95. !macroend
  96. Section /o ".NET Framework 4 Client Profile" dot_net_framework_index
  97. SectionIn 1 RO
  98. SetOutPath $TEMP
  99. File ${DOT_NET_FRAMEWORK_EXE}
  100. ClearErrors
  101. ExecWait '"$TEMP\${DOT_NET_FRAMEWORK_EXE}" /passive /norestart /chainingpackage "${SSH_HANDLER_NAME}"' $0
  102. IfErrors Failed
  103. Delete ${DOT_NET_FRAMEWORK_EXE}
  104. IntCmpU $0 0 Done
  105. IntCmpU $0 1641 RebootFlag
  106. IntCmpU $0 3010 RebootFlag
  107. Failed:
  108. Abort "Failed to install .NET Framework 4 Client Profile!"
  109. RebootFlag:
  110. SetRebootFlag true
  111. Done:
  112. SectionEnd
  113. Section "!${SSH_HANDLER}"
  114. SectionIn 1 RO
  115. SetOutPath -
  116. WriteUninstaller "${UNINST_EXE}"
  117. File "ssh-handler\bin\${SSH_HANDLER_CONFIGURATION}\${SWC_INPUT_TOOLKIT_DLL}"
  118. File "ssh-handler\bin\${SSH_HANDLER_CONFIGURATION}\${SWC_LAYOUT_TOOLKIT_DLL}"
  119. File "ssh-handler\bin\${SSH_HANDLER_CONFIGURATION}\${WPF_TOOLKIT_DLL}"
  120. File "ssh-handler\bin\${SSH_HANDLER_CONFIGURATION}\${SSH_HANDLER_EXE}"
  121. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  122. StrCmpS $MultiUser.InstallMode "CurrentUser" RegistryCurrentUser RegistryAllUsers
  123. RegistryCurrentUser:
  124. !insertmacro REGISTRY HKCU
  125. Goto RegistryDone
  126. RegistryAllUsers:
  127. !insertmacro REGISTRY HKLM
  128. RegistryDone:
  129. CreateDirectory "$SMPROGRAMS\${SSH_HANDLER_NAME}"
  130. StrCmpS $MultiUser.InstallMode "CurrentUser" StartMenuCurrentUser StartMenuAllUsers
  131. StartMenuCurrentUser:
  132. CreateShortcut /NoWorkingDir "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_SETTINGS_LNK}" \
  133. "$INSTDIR\${SSH_HANDLER_EXE}" "/settings" "" "" "" "" "Change settings for handling ssh:// URIs"
  134. Goto StartMenuDone
  135. StartMenuAllUsers:
  136. CreateShortcut /NoWorkingDir "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_USER_SETTINGS_LNK}" \
  137. "$INSTDIR\${SSH_HANDLER_EXE}" "/settings:user" "" "" "" "" "Change user settings for handling ssh:// URIs"
  138. CreateShortcut /NoWorkingDir "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_GLOBAL_SETTINGS_LNK}" \
  139. "$INSTDIR\${SSH_HANDLER_EXE}" "/settings:global" "" "" "" "" "Change global settings for handling ssh:// URIs"
  140. StartMenuDone:
  141. SectionEnd
  142. Section "un.${SSH_HANDLER}"
  143. StrCmpS $MultiUser.InstallMode "CurrentUser" StartMenuCurrentUser StartMenuAllUsers
  144. StartMenuCurrentUser:
  145. Delete /REBOOTOK "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_SETTINGS_LNK}"
  146. Goto StartMenuDone
  147. StartMenuAllUsers:
  148. Delete /REBOOTOK "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_USER_SETTINGS_LNK}"
  149. Delete /REBOOTOK "$SMPROGRAMS\${SSH_HANDLER_NAME}\${SSH_HANDLER_GLOBAL_SETTINGS_LNK}"
  150. StartMenuDone:
  151. RMDir /REBOOTOK "$SMPROGRAMS\${SSH_HANDLER_NAME}"
  152. Delete /REBOOTOK "$INSTDIR\${SSH_HANDLER_EXE}"
  153. Delete /REBOOTOK "$INSTDIR\${SWC_INPUT_TOOLKIT_DLL}"
  154. Delete /REBOOTOK "$INSTDIR\${SWC_LAYOUT_TOOLKIT_DLL}"
  155. Delete /REBOOTOK "$INSTDIR\${WPF_TOOLKIT_DLL}"
  156. Delete /REBOOTOK "$INSTDIR\${UNINST_EXE}"
  157. RMDir /REBOOTOK $INSTDIR
  158. StrCmpS $MultiUser.InstallMode "CurrentUser" RegistryCurrentUser RegistryAllUsers
  159. RegistryCurrentUser:
  160. !insertmacro UN_REGISTRY HKCU
  161. Goto RegistryDone
  162. RegistryAllUsers:
  163. !insertmacro UN_REGISTRY HKLM
  164. RegistryDone:
  165. SectionEnd
  166. Function .onInit
  167. !insertmacro MULTIUSER_INIT
  168. ClearErrors
  169. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" "Install"
  170. IfErrors EnableDotNetFramework
  171. IntCmp $0 1 Done
  172. EnableDotNetFramework:
  173. ClearErrors
  174. SectionGetFlags ${dot_net_framework_index} $1
  175. IntOp $1 $1 | ${SF_SELECTED}
  176. SectionSetFlags ${dot_net_framework_index} $1
  177. Done:
  178. FunctionEnd
  179. Function un.onInit
  180. !insertmacro MULTIUSER_UNINIT
  181. FunctionEnd
  182. # vim: autoindent