ssh-handler.nsi 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. !define SSH_HANDLER_VERSION "1.0.0"
  20. !define SSH_HANDLER_NAME "SSH Handler"
  21. !define SSH_HANDLER_AUTHOR "Douglas Thrift"
  22. Name "${SSH_HANDLER_NAME}"
  23. OutFile "ssh-handler-${SSH_HANDLER_VERSION}.exe"
  24. SetCompressor /SOLID lzma
  25. ShowInstDetails show
  26. ShowUninstDetails show
  27. XPStyle on
  28. VIProductVersion "${SSH_HANDLER_VERSION}.0"
  29. VIAddVersionKey "ProductName" "${SSH_HANDLER_NAME}"
  30. VIAddVersionKey "CompanyName" "${SSH_HANDLER_AUTHOR}"
  31. VIAddVersionKey "LegalCopyright" "Copyright 2013 ${SSH_HANDLER_AUTHOR}"
  32. VIAddVersionKey "FileDescription" "${SSH_HANDLER_NAME}"
  33. VIAddVersionKey "FileVersion" "${SSH_HANDLER_VERSION}.0"
  34. VIAddVersionKey "ProductVersion" "${SSH_HANDLER_VERSION}.0"
  35. !define SSH_HANDLER "${SSH_HANDLER_NAME} ${SSH_HANDLER_VERSION}"
  36. !define SSH_HANDLER_EXE "ssh-handler.exe"
  37. !define DOT_NET_FRAMEWORK_EXE "dotNetFx40_Client_setup.exe"
  38. !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
  39. !define UNINST_EXE "ssh-handler-uninst.exe"
  40. !define MULTIUSER_EXECUTIONLEVEL "Highest"
  41. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  42. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINST_REG}"
  43. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "UninstallString"
  44. !define MULTIUSER_INSTALLMODE_INSTDIR "${SSH_HANDLER_NAME}"
  45. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${UNINST_REG}"
  46. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallLocation"
  47. !define MULTIUSER_MUI
  48. !include "MultiUser.nsh"
  49. !include "MUI2.nsh"
  50. !include "FileFunc.nsh"
  51. !define MUI_COMPONENTSPAGE_NODESC
  52. !define MUI_FINISHPAGE_NOAUTOCLOSE
  53. !define MUI_FINISHPAGE_SHOWREADME "https://github.com/douglaswth/ssh-handler/blob/${SSH_HANDLER_VERSION}/README.md"
  54. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  55. !insertmacro MUI_PAGE_WELCOME
  56. !insertmacro MUI_PAGE_LICENSE LICENSE
  57. !insertmacro MUI_PAGE_COMPONENTS
  58. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  59. !insertmacro MUI_PAGE_DIRECTORY
  60. !insertmacro MUI_PAGE_INSTFILES
  61. !insertmacro MUI_PAGE_FINISH
  62. !define MUI_UNFINISHPAGE_NOAUTOCLOSE
  63. !insertmacro MUI_UNPAGE_WELCOME
  64. !insertmacro MUI_UNPAGE_CONFIRM
  65. !insertmacro MUI_UNPAGE_INSTFILES
  66. !insertmacro MUI_UNPAGE_FINISH
  67. !insertmacro MUI_LANGUAGE "English"
  68. !macro REGISTRY BASE_KEY
  69. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "" "URL:SSH Protocol"
  70. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "URL Protocol" ""
  71. WriteRegStr ${BASE_KEY} "Software\Classes\ssh\shell\open\command" "" '"$INSTDIR\${SSH_HANDLER_EXE}" "%1"'
  72. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayName" "$(^Name)"
  73. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayVersion" "${SSH_HANDLER_VERSION}"
  74. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "EstimatedSize" $0
  75. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "Publisher" "${SSH_HANDLER_AUTHOR}"
  76. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}"
  77. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "InstallLocation" "$INSTDIR"
  78. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoModify" 1
  79. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoRepair" 1
  80. !macroend
  81. !macro UN_REGISTRY BASE_KEY
  82. DeleteRegKey ${BASE_KEY} "Software\Classes\ssh"
  83. DeleteRegKey ${BASE_KEY} "${UNINST_REG}"
  84. !macroend
  85. Section /o ".NET Framework 4 Client Profile" dot_net_framework_index
  86. SectionIn 1 RO
  87. SetOutPath $TEMP
  88. File ${DOT_NET_FRAMEWORK_EXE}
  89. ClearErrors
  90. ExecWait '"$TEMP\${DOT_NET_FRAMEWORK_EXE}" /passive /norestart /chainingpackage "${SSH_HANDLER_NAME}"' $0
  91. IfErrors Failed
  92. Delete ${DOT_NET_FRAMEWORK_EXE}
  93. IntCmpU $0 0 Done
  94. IntCmpU $0 1641 RebootFlag
  95. IntCmpU $0 3010 RebootFlag
  96. Failed:
  97. Abort "Failed to install .NET Framework 4 Client Profile!"
  98. RebootFlag:
  99. SetRebootFlag true
  100. Done:
  101. SectionEnd
  102. Section "!${SSH_HANDLER}"
  103. SectionIn 1 RO
  104. SetOutPath -
  105. WriteUninstaller "${UNINST_EXE}"
  106. File "ssh-handler\bin\Release\${SSH_HANDLER_EXE}"
  107. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  108. StrCmpS $MultiUser.InstallMode "CurrentUser" CurrentUser AllUsers
  109. CurrentUser:
  110. !insertmacro REGISTRY HKCU
  111. Goto Done
  112. AllUsers:
  113. !insertmacro REGISTRY HKLM
  114. Done:
  115. SectionEnd
  116. Section "un.${SSH_HANDLER}"
  117. Delete /REBOOTOK "$INSTDIR\${SSH_HANDLER_EXE}"
  118. Delete /REBOOTOK "$INSTDIR\${UNINST_EXE}"
  119. RMDir /REBOOTOK $INSTDIR
  120. StrCmpS $MultiUser.InstallMode "CurrentUser" CurrentUser AllUsers
  121. CurrentUser:
  122. !insertmacro UN_REGISTRY HKCU
  123. Goto Done
  124. AllUsers:
  125. !insertmacro UN_REGISTRY HKLM
  126. Done:
  127. SectionEnd
  128. Function .onInit
  129. !insertmacro MULTIUSER_INIT
  130. ClearErrors
  131. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" "Install"
  132. IfErrors EnableDotNetFramework
  133. IntCmp $0 1 Done
  134. EnableDotNetFramework:
  135. ClearErrors
  136. SectionGetFlags ${dot_net_framework_index} $1
  137. IntOp $1 $1 | ${SF_SELECTED}
  138. SectionSetFlags ${dot_net_framework_index} $1
  139. Done:
  140. FunctionEnd
  141. Function un.onInit
  142. !insertmacro MULTIUSER_UNINIT
  143. FunctionEnd
  144. # vim: autoindent