1#................- 2#. Date of creation: 2020-05-06 3#. Name: installer.nsi 4#................- 5#..- Package parameters ... 6SetCompress force 7SetCompressor lzma 8!include LogicLib.nsh 9!include MUI2.nsh 10!include WinMessages.nsh 11!include x64.nsh 12!insertmacro MUI_PAGE_WELCOME 13!insertmacro MUI_PAGE_LICENSE "license.txt" 14!insertmacro MUI_PAGE_DIRECTORY 15!insertmacro MUI_PAGE_INSTFILES 16!insertmacro MUI_PAGE_FINISH 17!insertmacro MUI_UNPAGE_CONFIRM 18!insertmacro MUI_UNPAGE_INSTFILES 19!insertmacro MUI_LANGUAGE "English" 20 21#... Installation Windows Parameters .. 22!define APPNAME "vchanger" 23!define COMPANYNAME "Josh Fisher" 24!define DESCRIPTION "A virtual disk autochanger for Bacula" 25# These three must be integers 26!define VERSIONMAJOR 1 27!define VERSIONMINOR 0 28!define VERSIONBUILD 3 29# These will be displayed by the "Click here for support information" link in "Add/Remove Programs" 30!define HELPURL "http://sourceforge.net/projects/vchanger/" # "Support Information" link 31Name "vchanger 1.0.3" 32VIProductVersion "1.0.3.0" 33VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "vchanger Installer" 34VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (c) Josh Fisher 2008-2020" 35VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "vchanger Windows Installer" 36VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "1.0.3" 37ShowInstDetails nevershow 38SilentInstall normal 39RequestExecutionLevel admin 40AutoCloseWindow True 41OutFile "vchanger-1.0.3.exe" 42 43PageEx license 44 LicenseData "license.txt" 45PageExEnd 46Page directory 47Page instfiles 48 49UninstPage uninstConfirm 50UninstPage instfiles 51 52Section "vchanger 32-bit" SEC0001 53 SectionIn RO 54 SetOutPath $INSTDIR 55 ClearErrors 56 CreateDirectory "$APPDATA\vchanger" 57 IfErrors 0 +3 58 MessageBox MB_OK 'Could not create vchanger work directory' 59 Quit 60 File license.txt 61 File ReleaseNotes.txt 62 File vchangerHowto.html 63 File vchanger-example.conf 64 File vchanger.exe 65 WriteUninstaller "uninstall.exe" 66 IfFileExists "$APPDATA\vchanger\vchanger.conf" +2 0 67 CopyFiles "$INSTDIR\vchanger-example.conf" "$APPDATA\vchanger\vchanger.conf" 68 WriteRegStr HKLM "Software\vchanger" "Install_Dir" "$INSTDIR" 69 ; Write the uninstall keys for Windows 70 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "DisplayName" "vchanger" 71 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "UninstallString" '"$INSTDIR\uninstall.exe"' 72 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "NoModify" 1 73 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "NoRepair" 1 74 CreateDirectory "$SMPROGRAMS\vchanger" 75 CreateShortCut "$SMPROGRAMS\vchanger\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 76 CreateShortCut "$SMPROGRAMS\vchanger\vchanger Howto.lnk" "$INSTDIR\vchangerHowto.html" "" "$INSTDIR\vchangerHowto.html" 0 77 CreateShortcut "$SMPROGRAMS\vchanger\vchanger config.lnk" "$PROGRAMFILES32\Windows NT\Accessories\wordpad.exe" "$APPDATA\vchanger\vchanger.conf" 78SectionEnd 79 80Section "vchanger 64-bit" SEC0002 81 SectionIn RO 82 SetOutPath $INSTDIR 83 ClearErrors 84 CreateDirectory "$APPDATA\vchanger" 85 IfErrors 0 +3 86 MessageBox MB_OK 'Could not create vchanger work directory' 87 Quit 88 File license.txt 89 File ReleaseNotes.txt 90 File vchangerHowto.html 91 File vchanger-example.conf 92 File "/oname=vchanger.exe" vchanger64.exe 93 WriteUninstaller "uninstall.exe" 94 IfFileExists "$APPDATA\vchanger\vchanger.conf" +2 0 95 CopyFiles "$INSTDIR\vchanger-example.conf" "$APPDATA\vchanger\vchanger.conf" 96 WriteRegStr HKLM "Software\vchanger" "Install_Dir" "$INSTDIR" 97 ; Write the uninstall keys for Windows 98 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "DisplayName" "vchanger" 99 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "UninstallString" '"$INSTDIR\uninstall.exe"' 100 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "NoModify" 1 101 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" "NoRepair" 1 102 CreateDirectory "$SMPROGRAMS\vchanger" 103 CreateShortCut "$SMPROGRAMS\vchanger\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 104 CreateShortCut "$SMPROGRAMS\vchanger\vchanger Howto.lnk" "$INSTDIR\vchangerHowto.html" "" "$INSTDIR\vchangerHowto.html" 0 105 CreateShortcut "$SMPROGRAMS\vchanger\vchanger config.lnk" "$PROGRAMFILES64\Windows NT\Accessories\wordpad.exe" "$APPDATA\vchanger\vchanger.conf" 106SectionEnd 107 108# Uninstaller Section 109Section "Uninstall" 110 # Remove shortcuts, if any 111 Delete "$SMPROGRAMS\vchanger\*.*" 112 RMDir "$SMPROGRAMS\vchanger" 113 114 # Remove files and uninstaller 115 Delete $INSTDIR\vchanger.exe 116 Delete $INSTDIR\license.txt 117 Delete $INSTDIR\ReleaseNotes.txt 118 Delete $INSTDIR\vchangerHowto.html 119 Delete $INSTDIR\vchanger-example.conf 120 Delete $INSTDIR\uninstall.exe 121 RMDir "$INSTDIR" 122 123 # Remove information from the registry 124 DeleteRegKey HKLM "Software\vchanger" 125 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\vchanger" 126SectionEnd 127 128Function .onInit 129 SetShellVarContext all 130 #Determine the bitness of the OS and enable the correct section 131 ${If} ${RunningX64} 132 SectionSetFlags ${SEC0001} ${SECTION_OFF} 133 SectionSetFlags ${SEC0002} ${SF_SELECTED} 134 StrCpy $INSTDIR "$PROGRAMFILES64\vchanger" 135 SetRegView 64 136 ${Else} 137 SectionSetFlags ${SEC0002} ${SECTION_OFF} 138 SectionSetFlags ${SEC0001} ${SF_SELECTED} 139 StrCpy $INSTDIR "$PROGRAMFILES32\vchanger" 140 SetRegView 32 141 ${EndIf} 142FunctionEnd 143 144Function un.onInit 145 SetShellVarContext all 146 #Determine the bitness of the OS and enable the correct section 147 ${If} ${RunningX64} 148 StrCpy $INSTDIR "$PROGRAMFILES64\vchanger" 149 SetRegView 64 150 ${Else} 151 StrCpy $INSTDIR "$PROGRAMFILES32\vchanger" 152 SetRegView 32 153 ${EndIf} 154FunctionEnd 155 156Function .onInstSuccess 157 MessageBox MB_OK "You have successfully installed vchanger." 158FunctionEnd 159