ssh-handler.nsi 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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_FINISHPAGE_NOAUTOCLOSE
  52. !insertmacro MUI_PAGE_WELCOME
  53. !insertmacro MUI_PAGE_LICENSE LICENSE
  54. !insertmacro MUI_PAGE_COMPONENTS
  55. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  56. !insertmacro MUI_PAGE_DIRECTORY
  57. !insertmacro MUI_PAGE_INSTFILES
  58. !insertmacro MUI_PAGE_FINISH
  59. !define MUI_UNFINISHPAGE_NOAUTOCLOSE
  60. !insertmacro MUI_UNPAGE_WELCOME
  61. !insertmacro MUI_UNPAGE_CONFIRM
  62. !insertmacro MUI_UNPAGE_INSTFILES
  63. !insertmacro MUI_UNPAGE_FINISH
  64. !insertmacro MUI_LANGUAGE "English"
  65. !macro REGISTRY BASE_KEY
  66. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "" "URL:SSH Protocol"
  67. WriteRegStr ${BASE_KEY} "Software\Classes\ssh" "URL Protocol" ""
  68. WriteRegStr ${BASE_KEY} "Software\Classes\ssh\shell\open\command" "" '"$INSTDIR\${SSH_HANDLER_EXE}" "%1"'
  69. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayName" "$(^Name)"
  70. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "DisplayVersion" "${SSH_HANDLER_VERSION}"
  71. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "EstimatedSize" $0
  72. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "Publisher" "${SSH_HANDLER_AUTHOR}"
  73. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}"
  74. WriteRegStr ${BASE_KEY} "${UNINST_REG}" "InstallLocation" "$INSTDIR"
  75. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoModify" 1
  76. WriteRegDWORD ${BASE_KEY} "${UNINST_REG}" "NoRepair" 1
  77. !macroend
  78. !macro UN_REGISTRY BASE_KEY
  79. DeleteRegKey ${BASE_KEY} "Software\Classes\ssh"
  80. DeleteRegKey ${BASE_KEY} "${UNINST_REG}"
  81. !macroend
  82. Section /o ".NET Framework 4 Client Profile" dot_net_framework_index
  83. SectionIn 1 RO
  84. SetOutPath $TEMP
  85. File ${DOT_NET_FRAMEWORK_EXE}
  86. ClearErrors
  87. ExecWait '"$TEMP\${DOT_NET_FRAMEWORK_EXE}" /q /norestart /chainingpackage "${SSH_HANDLER_NAME}"' $0
  88. IfErrors Failed
  89. Delete ${DOT_NET_FRAMEWORK_EXE}
  90. IntCmpU $0 0 Done
  91. IntCmpU $0 1641 RebootFlag
  92. IntCmpU $0 3010 RebootFlag
  93. Failed:
  94. Abort "Failed to install .NET Framework 4 Client Profile!"
  95. RebootFlag:
  96. SetRebootFlag true
  97. Done:
  98. SectionEnd
  99. Section "!${SSH_HANDLER}"
  100. SectionIn 1 RO
  101. SetOutPath -
  102. WriteUninstaller "${UNINST_EXE}"
  103. File "ssh-handler\bin\Release\${SSH_HANDLER_EXE}"
  104. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  105. StrCmpS $MultiUser.InstallMode "CurrentUser" CurrentUser AllUsers
  106. CurrentUser:
  107. !insertmacro REGISTRY HKCU
  108. Goto Done
  109. AllUsers:
  110. !insertmacro REGISTRY HKLM
  111. Done:
  112. SectionEnd
  113. Section "un.${SSH_HANDLER}"
  114. Delete /REBOOTOK "$INSTDIR\${SSH_HANDLER_EXE}"
  115. Delete /REBOOTOK "$INSTDIR\${UNINST_EXE}"
  116. RMDir /REBOOTOK $INSTDIR
  117. StrCmpS $MultiUser.InstallMode "CurrentUser" CurrentUser AllUsers
  118. CurrentUser:
  119. !insertmacro UN_REGISTRY HKCU
  120. Goto Done
  121. AllUsers:
  122. !insertmacro UN_REGISTRY HKLM
  123. Done:
  124. SectionEnd
  125. Function .onInit
  126. !insertmacro MULTIUSER_INIT
  127. ClearErrors
  128. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Install"
  129. IfErrors Client
  130. IntCmpU $0 1 Done
  131. Client:
  132. ClearErrors
  133. ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" "Install"
  134. IfErrors EnableDotNetFramework
  135. IntCmp $0 1 Done
  136. EnableDotNetFramework:
  137. ClearErrors
  138. SectionGetFlags ${dot_net_framework_index} $1
  139. IntOp $1 $1 | ${SF_SELECTED}
  140. SectionSetFlags ${dot_net_framework_index} $1
  141. Done:
  142. FunctionEnd
  143. Function un.onInit
  144. !insertmacro MULTIUSER_UNINIT
  145. FunctionEnd
  146. # vim: autoindent