; $Id: msOfficeWinSami.nsi,v 1.3 2011/11/06 06:11:23 peter Exp $ !define DIVVUNVERSION "2.3" !define PLD_PRODUCT "Divvun_Sámi_Proofing_Tools_for_MS_Office${DIVVUNVERSION}" !define UninstRegKey "${SW_M_W_CV}\Uninstall\${PLD_PRODUCT}" CRCCheck On ; fill constants needed for samiregkeys_func.nsh !define ProdReg "57CB6F3B98FBBB64A855473F371F97EB" !define FeaNameReg "Sami_F" ; from InstallShield's ProFeatureName !include "${NSISDIR}\Contrib\Modern UI\System.nsh" ;needed for e.g. ${If} !include LogicLib.nsh !include MUI2.nsh ;Include Modern UI !include "CheckOfficeVersion.nsh" !include "process_checking_functions.nsh" !include "write_reg_multi_sz_func.nsh" !include "proofregkeys_func.nsh" !include "samiregkeys_func.nsh" ;-------------------------------- ; taken from different examples: ;; ShowInstDetails show ShowInstDetails "nevershow" ShowUninstDetails "nevershow" ;SetCompressor "bzip2" ;-------------------------------- ;General ; FN: do not use / in path, use _single_ backslash !define INPDIR "..\files" !define OUTDIR ".." ; no more "..\singleEXEs" !define RESDIR "..\resources" !define PLD_FOR_APPLICATION "Microsoft Office" ; used in Language-specific str ;put COMPONENTS_DESCRIPTION below component selection (otherwise to its right) ; must be defined before any 'insertmacro's: ; http://waforumweb-dtc0l-0.winamp.com/showthread.php?postid=2010750 !define MUI_COMPONENTSPAGE_SMALLDESC ;(No value) ;!undef MUI_ICON !define MUI_ICON "${RESDIR}\instsami.ico" ; override default NSIS icon !define MUI_UNICON "${MUI_ICON}" ; FN: define ICONs before LANGUAGEs to get the ICONs you want (NSIS quirk?) !include "languages.nsh" ;;FN !define MUI_VERSION "" Name ${PLD_PRODUCT} OutFile "${OUTDIR}\MSOfficeDivvunTools.exe" ; InstallDir "$PROGRAMFILES\${PLD_PRODUCT}" ; sets $INSTDIR InstallDir "C:\WINDOWS\Installer\{B3F6BC75-BF89-46BB-8A55-74F373F179BE}" ; as generated by InstallShield: {B3F6BC75-BF89-46BB-8A55-74F373F179BE} !define LANGFILE_DavviSami_NAME "Davvi Sámi" !define LANGFILE_LuleSami_NAME "Lule Sámi" !define LANGFILE_SouthernSami_NAME "South Sámi" Function .onInit !insertmacro MUI_LANGDLL_DISPLAY ; taken from example MultiLanguage.nsi #-- check if user has administrative rights call CheckAdministrativeRights ;DBG messageBox MB_OK "Deze installatie vereist administrator-rechten.$\r$\nU heeft deze.$\r$\nDe installatie wordt vervolgd." #-- check if the windows version is OK. Retrieve windows version major number call GetWindowsVersionFromRegistry ; messageBox MB_OK "windows version: $WindowsVersion" #-- Check if Office Apps are running. If app running: gives boxed error message, quits call CheckOfficeRunning ; messageBox MB_OK "End of process detection test." #-- Check Office version: retrieve office version, root directory, proofing tools dir ; MessageBox MB_OK "MS Office Root Folder: $OfficeRoot" ; MessageBox MB_OK "MS Office Version: $OfficeVersion" ; MessageBox MB_OK "Proofing tools directory: $ProofDir" ; Call GetProofDir ; derive ProofDIR var from registry Call GetOfficeVersionFromRegistry ; quits if no office version / unsupported office version Strcpy $ApplicationDir "C:\Backup\Divvun" IfFileExists "$ApplicationDir" HaveApplicationDir CreateDirectory "$ApplicationDir" ;MessageBox MB_OK "created Application Directory: $ApplicationDir" HaveApplicationDir: ;MessageBox MB_OK "MS Office version found: $OvcOfficeVersion" ; debug text box, normally commented out ;MessageBox MB_OK "MS Office Root Folder: $OvcOfficeRoot" ;MessageBox MB_OK "Proofing tools directory: $OvcProofDir" ;MessageBox MB_OK "Windows version: $WindowsVersion" ;MessageBox MB_OK "64 bits: $IsWin64" ;MessageBox MB_OK "Application Directory: $ApplicationDir" ;MessageBox MB_OK "Office 2010 override base: $o2010_base" ;Quit Call SetRegKeysForPackage ; set the 2 keys that are always required FunctionEnd Function un.onInit Call un.GetOfficeVersionFromRegistry ; quits if no office version / unsupported office version ;MessageBox MB_OK "MS Office version: $OvcOfficeVersion" ; debug text box, normally commented out FunctionEnd ;-------------------------------- ;Modern UI Configuration ; apparently out of use ;!define MUI_WELCOMEPAGE ;!define MUI_LICENSEPAGE ;!define MUI_DIRECTORYPAGE ;!define MUI_ABORTWARNING ;!define MUI_FINISHPAGE ;!define MUI_UNINSTALLER ;no effect? !define MUI_UNCONFIRMPAGE ; http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html: Installer pages ;no: MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "$(LicenseFileByLang)" !insertmacro MUI_PAGE_COMPONENTS ; !insertmacro MUI_PAGE_DIRECTORY ; choose Destination Directory, not needed ;no: MUI_PAGE_STARTMENU pageid variable !insertmacro MUI_PAGE_INSTFILES ;no: MUI_PAGE_FINISH ; Uninstaller pages ;err !insertmacro MUI_UNPAGE_WELCOME ; !insertmacro MUI_UNPAGE_CONFIRM ; shows 'GUID' as dirname ;no: MUI_UNPAGE_LICENSE textfile ; !insertmacro MUI_UNPAGE_COMPONENTS ; not needed, always uninstall all ;no: MUI_UNPAGE_DIRECTORY !insertmacro MUI_UNPAGE_INSTFILES ;no: MUI_UNPAGE_FINISH ;;FN NotFound: !insertmacro MUI_SYSTEM ;-------------------------------- ;Installer Sections Section "$(CompSamiNort)" ; "Northern Sami" ; " (Davvisámegiella)" SetOutPath "$OvcProofDIR" File "${INPDIR}\${HY_ENG_NORT}" File "${INPDIR}\${HY_DIC_NORT}" File "${INPDIR}\${HY_SPDIC_NORT}" ; registry key for this one only for Uninst File "${INPDIR}\${SP_ENG_NORT}" File "${INPDIR}\${SP_DIC_NORT}" StrCmp "$OvcOfficeVersion" "2010" F_NS_2010found F_NS_No2010Found F_NS_2010found: ;MessageBox MB_OK "office 2010 alternative" Call SetRegKeysFor2010SamiNortSp Goto F_NS_OffVerFound F_NS_No2010Found: ;MessageBox MB_OK "office < 2010 alternative" Call SetRegKeysForSamiNortSP F_NS_OffVerFound: Call SetRegKeysForSamiNortHY SectionEnd Section "$(CompSamiLule)" ; "Lule Sami" ; " (Julevsámegiella)" SetOutPath "$OvcProofDIR" File "${INPDIR}\${HY_ENG_LULE}" File "${INPDIR}\${HY_DIC_LULE}" File "${INPDIR}\${HY_SPDIC_LULE}" ; registry key for this one only for Uninst File "${INPDIR}\${SP_ENG_LULE}" File "${INPDIR}\${SP_DIC_LULE}" StrCmp "$OvcOfficeVersion" "2010" F_LS_2010found F_LS_No2010Found F_LS_2010Found: ;MessageBox MB_OK "office 2010 alternative" Call SetRegKeysFor2010SamiLuleSp Goto F_LS_OffVerFound F_LS_No2010found: ;MessageBox MB_OK "office < 2010 alternative" Call SetRegKeysForSamiLuleSP F_LS_OffVerFound: Call SetRegKeysForSamiLuleHY SectionEnd Section "$(CompSamiSout)" ; "Southern Sami" ; " (Lullisámegiella)" SetOutPath "$OvcProofDIR" File "${INPDIR}\${HY_ENG_SOUT}" File "${INPDIR}\${HY_DIC_SOUT}" File "${INPDIR}\${HY_SPDIC_SOUT}" ; registry key for this one only for Uninst File "${INPDIR}\${SP_ENG_SOUT}" File "${INPDIR}\${SP_DIC_SOUT}" StrCmp "$OvcOfficeVersion" "2010" F_SS_2010found F_SS_No2010Found F_SS_2010Found: ;MessageBox MB_OK "office 2010 alternative" Call SetRegKeysFor2010SamiSoutSp Goto F_SS_OffVerFound F_SS_No2010found: ;MessageBox MB_OK "office < 2010 alternative" Call SetRegKeysForSamiSoutSP F_SS_OffVerFound: Call SetRegKeysForSamiSoutHY SectionEnd Section "-Instalways" ;;FN hidden (i.e. cannot be disabled) section SetOutPath "$INSTDIR" ; otherwise Uninstall.exe won't be written (way below) ;write uninstall information to the registry, no more " (remove only)" WriteRegStr HKLM "${UninstRegKey}" "DisplayName" "${PLD_PRODUCT}" WriteRegStr HKLM "${UninstRegKey}" "UninstallString" "$INSTDIR\Uninstall.exe" ; FN make sure we get no "Change/Remove" but only a "Remove" button: WriteRegDWORD HKLM "${UninstRegKey}" "NoModify" 1 ;WriteRegDWORD HKLM "${UninstRegKey}" "NoRemove" 1 ;WriteRegDWORD HKLM "${UninstRegKey}" "NoRepair" 1 ;WriteUninstaller "$INSTDIR\Uninstall.exe" writeUninstaller $ApplicationDir\remove_SamiProofingTools.exe SectionEnd ;-------------------------------- ;Uninstaller Section Section "un.AllSami" call un.CheckAdministrativeRights call un.CheckOfficeRunning call un.GetWindowsVersionFromRegistry call un.GetOfficeVersionFromRegistry StrCmp "$OvcOfficeVersion" "2010" un_F_2010found un_F_No2010Found un_F_2010Found: ;MessageBox MB_OK "office 2010 alternative" Goto un_F_OffVerFound un_F_No2010found: ;MessageBox MB_OK "office < 2010 alternative" Call un.DelByRegKeysForSamiNortHY Call un.DelByRegKeysForSamiNortSP Call un.DelByRegKeysForSamiLuleHY Call un.DelByRegKeysForSamiLuleSP Call un.DelByRegKeysForSamiSoutHY Call un.DelByRegKeysForSamiSoutSP un_F_OffVerFound: ;Delete Files RMDir /r "$INSTDIR\*.*" ;Remove the installation directory RMDir "$INSTDIR" ;Delete Start Menu Shortcuts ;Delete Uninstaller And Unistall Registry Entries ;not set, so no: DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PLD_PRODUCT}" DeleteRegKey HKEY_LOCAL_MACHINE "${UninstRegKey}" Call un.DelRegKeysForPackage SectionEnd ;-------------------------------- ;MessageBox Section ;Function that calls a messagebox when installation finished correctly Function .onInstSuccess ;; MessageBox MB_OK "You have successfully installed ${PLD_PRODUCT}. Use the desktop icon to start the program." FunctionEnd Function un.onUninstSuccess ;; MessageBox MB_OK "You have successfully uninstalled ${PLD_PRODUCT}." FunctionEnd ;eof