|
| 1 | +; ProgramLauncher Installer NSIS Script |
| 2 | +; get NSIS at http://nsis.sourceforge.net/Download |
| 3 | +; As a program that all Power PC users should have, Notepad++ is recommended to edit this file |
| 4 | + |
| 5 | +;Icon "My Project\document-properties.ico" |
| 6 | +Caption "ProgramLauncher Installer" |
| 7 | +Name "ProgramLauncher" |
| 8 | +AutoCloseWindow true |
| 9 | +ShowInstDetails show |
| 10 | + |
| 11 | +LicenseBkColor /windows |
| 12 | +LicenseData "LICENSE.md" |
| 13 | +LicenseForceSelection checkbox "I have read and understand this notice" |
| 14 | +LicenseText "Please read the notice below before installing ProgramLauncher. If you understand the notice, click the checkbox below and click Next." |
| 15 | + |
| 16 | +InstallDir $PROGRAMFILES\WalkmanOSS |
| 17 | + |
| 18 | +OutFile "bin\Release\ProgramLauncher-Installer.exe" |
| 19 | + |
| 20 | +; Pages |
| 21 | + |
| 22 | +Page license |
| 23 | +Page components |
| 24 | +Page directory |
| 25 | +Page instfiles |
| 26 | +UninstPage uninstConfirm |
| 27 | +UninstPage instfiles |
| 28 | + |
| 29 | +; Sections |
| 30 | + |
| 31 | +Section "Executable & Uninstaller" |
| 32 | + SectionIn RO |
| 33 | + SetOutPath $INSTDIR |
| 34 | + File "bin\Release\ProgramLauncher.exe" |
| 35 | + WriteUninstaller "ProgramLauncher-Uninst.exe" |
| 36 | +SectionEnd |
| 37 | + |
| 38 | +Section "Start Menu Shortcuts" |
| 39 | + CreateDirectory "$SMPROGRAMS\WalkmanOSS" |
| 40 | + CreateShortCut "$SMPROGRAMS\WalkmanOSS\ProgramLauncher.lnk" "$INSTDIR\ProgramLauncher.exe" "" "$INSTDIR\ProgramLauncher.exe" "" "" "" "ProgramLauncher" |
| 41 | + CreateShortCut "$SMPROGRAMS\WalkmanOSS\Uninstall ProgramLauncher.lnk" "$INSTDIR\ProgramLauncher-Uninst.exe" "" "" "" "" "" "Uninstall ProgramLauncher" |
| 42 | + ;Syntax for CreateShortCut: link.lnk target.file [parameters [icon.file [icon_index_number [start_options [keyboard_shortcut [description]]]]]] |
| 43 | +SectionEnd |
| 44 | + |
| 45 | +Section "Desktop Shortcut" |
| 46 | + CreateShortCut "$DESKTOP\ProgramLauncher.lnk" "$INSTDIR\ProgramLauncher.exe" "" "$INSTDIR\ProgramLauncher.exe" "" "" "" "ProgramLauncher" |
| 47 | +SectionEnd |
| 48 | + |
| 49 | +Section "Quick Launch Shortcut" |
| 50 | + CreateShortCut "$QUICKLAUNCH\ProgramLauncher.lnk" "$INSTDIR\ProgramLauncher.exe" "" "$INSTDIR\ProgramLauncher.exe" "" "" "" "ProgramLauncher" |
| 51 | +SectionEnd |
| 52 | + |
| 53 | +SubSection "Shell integration" |
| 54 | + Section "Set as default HTTP and HTTPS handler" |
| 55 | + WriteRegStr HKCR "http\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 56 | + WriteRegStr HKCR "https\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 57 | + WriteRegStr HKLM "SOFTWARE\Classes\http\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 58 | + WriteRegStr HKLM "SOFTWARE\Classes\https\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 59 | + WriteRegStr HKCU "Software\Classes\http\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 60 | + WriteRegStr HKCU "Software\Classes\https\shell\open\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 61 | + SectionEnd |
| 62 | + |
| 63 | + Section "Add to context menu for all files" |
| 64 | + WriteRegStr HKCR "*\shell\ProgramLauncher" "" "ProgramLauncher..." |
| 65 | + WriteRegStr HKCR "*\shell\ProgramLauncher" "Icon" "$INSTDIR\ProgramLauncher.exe" |
| 66 | + WriteRegStr HKCR "*\shell\ProgramLauncher\command" "" "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 67 | + SectionEnd |
| 68 | +SubSectionEnd |
| 69 | + |
| 70 | +; Functions |
| 71 | + |
| 72 | +Function .onInit |
| 73 | + MessageBox MB_YESNO "This will install ProgramLauncher. Do you wish to continue?" IDYES gogogo |
| 74 | + Abort |
| 75 | + gogogo: |
| 76 | + SetShellVarContext all |
| 77 | + SetAutoClose true |
| 78 | +FunctionEnd |
| 79 | + |
| 80 | +Function .onInstSuccess |
| 81 | + MessageBox MB_YESNO "Install Succeeded! Open ReadMe?" IDNO NoReadme |
| 82 | + ExecShell "open" "https://github.com/Walkman100/ProgramLauncher/blob/master/README.md#programlauncher-" |
| 83 | + NoReadme: |
| 84 | +FunctionEnd |
| 85 | + |
| 86 | +; Uninstaller |
| 87 | + |
| 88 | +!include LogicLib.nsh ; For ${IF} logic |
| 89 | +Section "Uninstall" |
| 90 | + Delete "$INSTDIR\ProgramLauncher-Uninst.exe" ; Remove Application Files |
| 91 | + Delete "$INSTDIR\ProgramLauncher.exe" |
| 92 | + RMDir "$INSTDIR" |
| 93 | + |
| 94 | + Delete "$SMPROGRAMS\WalkmanOSS\ProgramLauncher.lnk" ; Remove Start Menu Shortcuts & Folder |
| 95 | + Delete "$SMPROGRAMS\WalkmanOSS\Uninstall ProgramLauncher.lnk" |
| 96 | + RMDir "$SMPROGRAMS\WalkmanOSS" |
| 97 | + |
| 98 | + Delete "$DESKTOP\ProgramLauncher.lnk" ; Remove Desktop Shortcut |
| 99 | + Delete "$QUICKLAUNCH\ProgramLauncher.lnk" ; Remove Quick Launch Shortcut |
| 100 | + |
| 101 | + ; Remove HTTP/HTTPS handlers if they are still set to ProgramLauncher: |
| 102 | + ReadRegStr $0 HKCR "http\shell\open\command" "" |
| 103 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 104 | + WriteRegStr HKCR "http\shell\open\command" "" "" |
| 105 | + ${ENDIF} |
| 106 | + |
| 107 | + ReadRegStr $0 HKCR "https\shell\open\command" "" |
| 108 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 109 | + WriteRegStr HKCR "https\shell\open\command" "" "" |
| 110 | + ${ENDIF} |
| 111 | + |
| 112 | + ReadRegStr $0 HKLM "SOFTWARE\Classes\http\shell\open\command" "" |
| 113 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 114 | + WriteRegStr HKLM "SOFTWARE\Classes\http\shell\open\command" "" "" |
| 115 | + ${ENDIF} |
| 116 | + |
| 117 | + ReadRegStr $0 HKLM "SOFTWARE\Classes\https\shell\open\command" "" |
| 118 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 119 | + WriteRegStr HKLM "SOFTWARE\Classes\https\shell\open\command" "" "" |
| 120 | + ${ENDIF} |
| 121 | + |
| 122 | + ReadRegStr $0 HKCU "Software\Classes\http\shell\open\command" "" |
| 123 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 124 | + WriteRegStr HKCU "Software\Classes\http\shell\open\command" "" "" |
| 125 | + ${ENDIF} |
| 126 | + |
| 127 | + ReadRegStr $0 HKCU "Software\Classes\https\shell\open\command" "" |
| 128 | + ${IF} $0 == "$\"$INSTDIR\ProgramLauncher.exe$\" $\"%1$\"" |
| 129 | + WriteRegStr HKCU "Software\Classes\https\shell\open\command" "" "" |
| 130 | + ${ENDIF} |
| 131 | + |
| 132 | + DeleteRegKey HKCR "*\shell\ProgramLauncher" ; Remove context menu item |
| 133 | +SectionEnd |
| 134 | + |
| 135 | +; Uninstaller Functions |
| 136 | + |
| 137 | +Function un.onInit |
| 138 | + MessageBox MB_YESNO "This will uninstall ProgramLauncher. Continue?" IDYES NoAbort |
| 139 | + Abort ; causes uninstaller to quit. |
| 140 | + NoAbort: |
| 141 | + SetShellVarContext all |
| 142 | + SetAutoClose true |
| 143 | +FunctionEnd |
| 144 | + |
| 145 | +Function un.onUninstFailed |
| 146 | + MessageBox MB_OK "Uninstall Cancelled" |
| 147 | +FunctionEnd |
| 148 | + |
| 149 | +Function un.onUninstSuccess |
| 150 | + MessageBox MB_OK "Uninstall Completed" |
| 151 | +FunctionEnd |
0 commit comments