Welcome, Guest. Please login or register.

Login with username, password and session length
Forums Search:  


Author Topic: Problem with NSIS and registry entries  (Read 39619 times)

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Problem with NSIS and registry entries
« on: February 24, 2010, 07:13:59 AM »
When I build a map installer with NSIS everything seems to install properly but the installer is not writing the registry entries. I have to manually run the xxx.reg file to get the map to load in map source This happens even when the installer is run as administrator. I am using the map_install.nis file from this site and the OS is windows 7. Does anyone have a fix for this or any ideas?

Prolly a different problem in XP
Just tried it in XP the NC map installer from this site works and I can load my maps into mapsource with mapsettoolkit but when I use the install.exe i made I get problem occurred with installation error and mapsource crashes. tried to manually run the  xx.reg file and got the same errors and have to uninstall my maps for mapsource to work again. BTW I have tried several versions of mapsource and they all behave the same way.
Anyway I am sure its something simple i am overlooking in the xx.nis script or maybe I should try a different program than NSIS.

Thanks
Freecat

maps4gps

  • Expert Advisor
  • *****
  • Posts: 1524
  • Karma: 17
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #1 on: February 24, 2010, 07:24:30 AM »
Might be easier for us to detect an issue in your NSIS file if you attached it.

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #2 on: February 24, 2010, 09:25:12 AM »
Thanks for the fast replies. Here is a copy of the .nis file file for the custom type test. The other test file is the same except for lines 15,109,119 are commented out.
Code: [Select]
;--------------------------------
; install.nsi
;--------------------------------
  !include "MUI2.nsh"

; Configuration parameters
  !define MAP_DESC_NAME       "test Topo Map"
  !define MAP_SHORT_NAME      "test"
  !define MAP_URL             "http://www.freecat.com/"
  !define MAP_EMAIL           "[email protected]"
  !define MAP_COPYRIGHT       "Copyright (C) 2010 freecat.com"
  !define MAP_VERSION         "1.0"
  !define MAP_REL_DATE        "22 Feb 2010"
  !define MAP_ID              301E             ; Family ID = 4644 (dec) = 1224 (hex) = 2412 (hex flipped) --> http://www.geocities.com/binary_converter/
  !define MAP_TYPE            23837773          ; only if using custom types
  !define DIRECTORY   "C:\Users\Freecat\Desktop\maptest3\"
  !define EXE_FILE            "${DIRECTORY}test_topo_install.exe"

;  !define INSTALL_ICON        "C:\gps_maps\arizona_topo\complete\favicon.ico"
;  !define INSTALL_IMAGE       "C:\gps_maps\left_header.bmp"
;  !define INSTALL_LICENSE     "C:\gps_maps\license.txt"
;  !define INSTALL_README      "$INSTDIR\readme.txt"
;  !define INSTALL_MSG         "${MAP_DESC_NAME} - Maps for Garmin GPS Units$\r$\n${MAP_URL}$\r$\nVersion ${MAP_VERSION} - ${MAP_REL_DATE}$\r$\n$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\n$\r$\n${MAP_COPYRIGHT}$\r$\nThis software is provided 'as-is', without any express or implied warranty.  In no event will the author(s) be held liable for any damages arising from the use of this software."
  !define INSTALL_MSG         "This wizard will guide you through the installation of ${MAP_DESC_NAME} version ${MAP_VERSION} (${MAP_REL_DATE}) for Garmin GPS Units.$\r$\n$\r$\n${MAP_URL}$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\nIt is recommended that you close all other applications before starting Setup.  This will make it possible to update relevant system files without having to reboot your computer.$\r$\n$\r$\nClick Next to continue."
 

; Setup installer
  Name       "${MAP_DESC_NAME}"
  OutFile    ${EXE_FILE}
  InstallDir "$PROGRAMFILES\${MAP_SHORT_NAME}"
  BrandingText " "


;--------------------------------
;Interface Settings
;--------------------------------
  !define MUI_ABORTWARNING
;  !define MUI_ICON   ${INSTALL_ICON}
;  !define MUI_UNICON ${INSTALL_ICON}

;--------------------------------
;Pages
;--------------------------------
; Generic welcome screen (optional)
;  !define MUI_WELCOMEFINISHPAGE_BITMAP ${INSTALL_IMAGE}
;  !insertmacro MUI_PAGE_WELCOME

; Custom welcome screen (optional)
  !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${MAP_DESC_NAME} Setup Wizard"
  !define MUI_WELCOMEPAGE_TEXT "${INSTALL_MSG}"
  !insertmacro MUI_PAGE_WELCOME

;  !define MUI_LICENSEPAGE_CHECKBOX
;  !insertmacro MUI_PAGE_LICENSE "${INSTALL_LICENSE}"

; Installation directory dialog
  !insertmacro MUI_PAGE_DIRECTORY

; Installation
  !insertmacro MUI_PAGE_INSTFILES
 
; Readme (optional)
;  !define MUI_FINISHPAGE_SHOWREADME "${INSTALL_README}"
  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
;--------------------------------
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
; The stuff to install
;--------------------------------
Section "Install"
;remove the old version first
  ReadRegStr $R0 HKLM \
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  "${MAP_DESC_NAME} is already installed. $\n$\nClick `OK` to remove the \
  previous version and upgrade or `Cancel` to cancel this upgrade." \
  IDOK uninst
  Abort
 
;Run the uninstaller
uninst:
  ClearErrors
  ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  IfErrors no_remove_uninstaller
    ;You can either use Delete /REBOOTOK in the uninstaller or add some code
    ;here to remove the uninstaller. Use a registry key to check
    ;whether the user has chosen to uninstall. If you are using an uninstaller
    ;components page, make sure all sections are uninstalled.
  no_remove_uninstaller:
 
done:
; Set output path to the installation directory.
  SetOutPath $INSTDIR
 
; Source files for creating installation
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.tdb"
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.img"
  File /a "C:\Users\Freecat\Desktop\maptest3\${MAP_TYPE}.typ"    ; only if using custom type
;  File /a ".\readme.txt"
  File /a "${DIRECTORY}*.img"

; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
SectionEnd

;--------------------------------
; Uninstaller
;--------------------------------
Section "Uninstall"

; Remove registry keys
  DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"

; Remove files and uninstaller
  Delete $INSTDIR\*.*
  Delete $INSTDIR\uninstall.exe

; Remove directories used
  RMDir "$INSTDIR"
SectionEnd


Seldom

  • Expert Advisor
  • *****
  • Posts: 1852
  • Karma: 19
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #3 on: February 24, 2010, 10:35:42 AM »
I've run OZ's plain vanilla NSIS installer script on both XP and Win7, without problems on install or uninstall, but I haven't used custom TYP files.  

Maps automatically go to the Program Files X86 folder in Win7 64bit.

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #4 on: February 24, 2010, 01:28:40 PM »
I just rebuilt my installer package with Clickteam's Install Creator and got the same behavior as NSIS. Then I set the installer to run the .reg file as visible at the end of the install process. Now at the last installer window a box pops up asking for permission to add to the registry, click ok  and the .reg entries installed ok and mapsource loads the maps perfectly  ;D. This worked with both standard and custom types but it's not as clean as having the installer write them. I am going to keep messing with NSIS and see if I can get it to work correctly.

-Oz-

  • Map Maker!
  • Administrator
  • Expert Advisor
  • *****
  • Posts: 1579
  • Karma: 27
    • View Profile
    • GPSFileDepot
Re: Problem with NSIS and registry entries
« Reply #5 on: February 24, 2010, 08:16:15 PM »
on win7 right click on your install and tell it to run as administrator; see if that works then we can narrow it down.

I've built the installs on xp and 7 (and even vista) and installed on all of those.
Dan Blomberg
Administrator - GPSFileDepot
GPS Units: Garmin Dakota 20, Garmin GPSMap 60csx, Nuvi 255W, Nuvi 250W, ForeRunner 110, Fenix 2, Tactix Bravo, Foretrex 401
See/Download My Maps!

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #6 on: February 25, 2010, 04:45:34 AM »
Thanks for all the help everyone. Oz I have run the installer as administrator and get the same behavior. I am going to create a small test mapset and go though everything again to see if i messed up somewhere. Will post what happens in a little while.
Freecat

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #7 on: February 25, 2010, 05:11:22 AM »
 ;D Ok problem solved the registry locations are wrong in the map_install.nis file

OLD FILE:
Code: [Select]
; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
SectionEnd

NEW FILE
Code: [Select]
; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
;  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
SectionEnd

Notice the only change is Wow6432Node folder entry. The test was done with a known working image of 1 24000 quad and the installer was run normally without admin rights in Win7 64B. The uninstaller works ok and removes all the associated registry entires.  Next I am going to test this on my map and will update this thread when I get done but I expect it to work.
Freecat

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #8 on: February 25, 2010, 05:47:38 AM »
NSIS Installer worked just fine with my map both with and without custom types. I think the script can be  modified the to check the registry and use the correct set of reg entries for the OS that it is being installed into. The NSIS registry plug-in looks like it is able to do this. I could give it a try but I am sure Oz can do it better.
Next I have to sort out my  previously mentioned issues on XP  WEEEEEEEEEE fun :-\

Below is a copy of the original .nsi script with only the registry changes made if anyone needs a copy: 
Code: [Select]
;--------------------------------
; install.nsi*********************** FOR WINDOWS 7 64 BIT***************************************
;--------------------------------
  !include "MUI2.nsh"

; Configuration parameters
  !define MAP_DESC_NAME       "Mississippi Topo Map"
  !define MAP_SHORT_NAME      "Mississippi Topo"
  !define MAP_URL             "http://www.gpsfiledepot.com/"
  !define MAP_EMAIL           "[email protected]"
  !define MAP_COPYRIGHT       "Copyright (C) 2008 GPSFileDepot.com"
  !define MAP_VERSION         "1.0"
  !define MAP_REL_DATE        "21 Jul 2008"
  !define MAP_ID              C10C             ; Family ID = 4644 (dec) = 1224 (hex) = 2412 (hex flipped) --> http://www.geocities.com/binary_converter/
;  !define MAP_TYPE            11224          ; only if using custom types
  !define DIRECTORY   "C:\gps_maps\mississippi_topo\release_version_1.00\"
  !define EXE_FILE            "${DIRECTORY}mstopo_install.exe"

;  !define INSTALL_ICON        "C:\gps_maps\arizona_topo\complete\favicon.ico"
;  !define INSTALL_IMAGE       "C:\gps_maps\left_header.bmp"
;  !define INSTALL_LICENSE     "C:\gps_maps\license.txt"
;  !define INSTALL_README      "$INSTDIR\readme.txt"
;  !define INSTALL_MSG         "${MAP_DESC_NAME} - Maps for Garmin GPS Units$\r$\n${MAP_URL}$\r$\nVersion ${MAP_VERSION} - ${MAP_REL_DATE}$\r$\n$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\n$\r$\n${MAP_COPYRIGHT}$\r$\nThis software is provided 'as-is', without any express or implied warranty.  In no event will the author(s) be held liable for any damages arising from the use of this software."
  !define INSTALL_MSG         "This wizard will guide you through the installation of ${MAP_DESC_NAME} version ${MAP_VERSION} (${MAP_REL_DATE}) for Garmin GPS Units.$\r$\n$\r$\n${MAP_URL}$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\nIt is recommended that you close all other applications before starting Setup.  This will make it possible to update relevant system files without having to reboot your computer.$\r$\n$\r$\nClick Next to continue."
 

; Setup installer
  Name       "${MAP_DESC_NAME}"
  OutFile    ${EXE_FILE}
  InstallDir "$PROGRAMFILES\${MAP_SHORT_NAME}"
  BrandingText " "

;--------------------------------
;Interface Settings
;--------------------------------
  !define MUI_ABORTWARNING
;  !define MUI_ICON   ${INSTALL_ICON}
;  !define MUI_UNICON ${INSTALL_ICON}

;--------------------------------
;Pages
;--------------------------------
; Generic welcome screen (optional)
;  !define MUI_WELCOMEFINISHPAGE_BITMAP ${INSTALL_IMAGE}
;  !insertmacro MUI_PAGE_WELCOME

; Custom welcome screen (optional)
  !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${MAP_DESC_NAME} Setup Wizard"
  !define MUI_WELCOMEPAGE_TEXT "${INSTALL_MSG}"
  !insertmacro MUI_PAGE_WELCOME

;  !define MUI_LICENSEPAGE_CHECKBOX
;  !insertmacro MUI_PAGE_LICENSE "${INSTALL_LICENSE}"

; Installation directory dialog
  !insertmacro MUI_PAGE_DIRECTORY

; Installation
  !insertmacro MUI_PAGE_INSTFILES
 
; Readme (optional)
;  !define MUI_FINISHPAGE_SHOWREADME "${INSTALL_README}"
  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
;--------------------------------
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
; The stuff to install
;--------------------------------
Section "Install"
;remove the old version first
  ReadRegStr $R0 HKLM \
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  "${MAP_DESC_NAME} is already installed. $\n$\nClick `OK` to remove the \
  previous version and upgrade or `Cancel` to cancel this upgrade." \
  IDOK uninst
  Abort
 
;Run the uninstaller
uninst:
  ClearErrors
  ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  IfErrors no_remove_uninstaller
    ;You can either use Delete /REBOOTOK in the uninstaller or add some code
    ;here to remove the uninstaller. Use a registry key to check
    ;whether the user has chosen to uninstall. If you are using an uninstaller
    ;components page, make sure all sections are uninstalled.
  no_remove_uninstaller:
 
done:
; Set output path to the installation directory.
  SetOutPath $INSTDIR
 
; Source files for creating installation
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.tdb"
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.img"
;  File /a "..\garmin\types\${MAP_TYPE}.typ"    ; only if using custom type
;  File /a ".\readme.txt"
  File /a "${DIRECTORY}*.img"

; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
;  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
SectionEnd

;--------------------------------
; Uninstaller
;--------------------------------
Section "Uninstall"

; Remove registry keys
  DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"

; Remove files and uninstaller
  Delete $INSTDIR\*.*
  Delete $INSTDIR\uninstall.exe

; Remove directories used
  RMDir "$INSTDIR"
SectionEnd

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #9 on: February 25, 2010, 06:30:53 AM »
I got everything working fine in xp with the original .nsi file. It must have been a issue with my mapsource install. Once I un.../reinstalled and updated mapsource my map installed without a issue, both with and without custom types.
Oz thanks for your help and for making the .nsi script. If not for this site :) and folks like you this type of project would be much more difficult to complete.

=^_^= Freecat=^_^=

-Oz-

  • Map Maker!
  • Administrator
  • Expert Advisor
  • *****
  • Posts: 1579
  • Karma: 27
    • View Profile
    • GPSFileDepot
Re: Problem with NSIS and registry entries
« Reply #10 on: February 27, 2010, 02:39:57 PM »
Hmm, the issue will be that in 32bit windows that doesn't exist so I think if someone uses a 32 bit windows they won't be able to install it...
Dan Blomberg
Administrator - GPSFileDepot
GPS Units: Garmin Dakota 20, Garmin GPSMap 60csx, Nuvi 255W, Nuvi 250W, ForeRunner 110, Fenix 2, Tactix Bravo, Foretrex 401
See/Download My Maps!

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #11 on: March 01, 2010, 02:33:43 AM »
Hi Oz
Your correct the script I posted will only work in 64 bit windows. Since NSIS scripts can read/write to the registry and also can check conditions (if statements), I think I can have the script check the bit type then load the 32 bit or the 64 bit reg entries based on the result of the condition check. NSIS has a registry plug-in that should make this easy.
http://nsis.sourceforge.net/Registry_plug-in
I am going to start  making the changes to the script as soon as I figure out how to get the OS bit type from the registry. I think I can just check for the Wow6432Node folder and if if the check returns true install the 64 bit reg entries and if not install the 32 bit reg entries.
Freecat

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #12 on: March 01, 2010, 08:26:43 AM »
All right I have the modified map_install.nsi script written, commented and tested. 8)
What I did was (also see script comments)

1- Put registry entries into separate functions for each Bit type
2-Run a check for a folder that is only on 64 bit systems
3-Execute the correct function based on the result of #2

NOTE FOR CUSTOM TYPES: Un-comment and adjust lines- 17, 109 ,159(for 64 bit), 186(for32bit)

 It works fine in Windows XP 32Bit and on Windows 7 64Bit. If anyone can test this script on Vista 32/64 and XP 64Bit and post back to this thread that  would be awesome. Also I can zip this file up and host it on my website or can I or a Mod put it into the download section here???
Anyhow here's the new script
Code: [Select]
;--------------------------------
;Multi-bit NSIS installer script**original script by Oz** modified 3-1-2010 by =^_^= Freecat =^_^= *****
;NOTE FOR CUSTOM TYPES: Un-comment and adjust lines- 17, 109, 159(for 64 bit), 186(for32bit)
; install.nsi
;--------------------------------
  !include "MUI2.nsh"
!include "Sections.nsh"
; Configuration parameters
  !define MAP_DESC_NAME       "Mississippi Topo Map"
  !define MAP_SHORT_NAME      "Mississippi_Topo"  ;<<<Name must match>>>.TDB file name ?????
  !define MAP_URL             "http://www.gpsfiledepot.com/"
  !define MAP_EMAIL           "[email protected]"
  !define MAP_COPYRIGHT       "Copyright (C) 2008 GPSFileDepot.com"
  !define MAP_VERSION         "1.0"
  !define MAP_REL_DATE        "21 Jul 2008"
  !define MAP_ID              C10C             ; Family ID = 4644 (dec) = 1224 (hex) = 2412 (hex flipped) --> http://www.geocities.com/binary_converter/
;  !define MAP_TYPE            11224          ; only if using custom types
  !define DIRECTORY  "C:\gps_maps\mississippi_topo\release_version_1.00\"
  !define EXE_FILE            "${DIRECTORY}mstopo_install.exe"

;  !define INSTALL_ICON        "C:\gps_maps\arizona_topo\complete\favicon.ico"
;  !define INSTALL_IMAGE       "C:\gps_maps\left_header.bmp"
;  !define INSTALL_LICENSE     "C:\gps_maps\license.txt"
;  !define INSTALL_README      "$INSTDIR\readme.txt"
;  !define INSTALL_MSG         "${MAP_DESC_NAME} - Maps for Garmin GPS Units$\r$\n${MAP_URL}$\r$\nVersion ${MAP_VERSION} - ${MAP_REL_DATE}$\r$\n$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\n$\r$\n${MAP_COPYRIGHT}$\r$\nThis software is provided 'as-is', without any express or implied warranty.  In no event will the author(s) be held liable for any damages arising from the use of this software."
  !define INSTALL_MSG         "This wizard will guide you through the installation of ${MAP_DESC_NAME} version ${MAP_VERSION} (${MAP_REL_DATE}) for Garmin GPS Units.$\r$\n$\r$\n${MAP_URL}$\r$\n$\r$\nPlease email ${MAP_EMAIL} with any questions or comments or if you paid for this map.$\r$\n$\r$\nIt is recommended that you close all other applications before starting Setup.  This will make it possible to update relevant system files without having to reboot your computer.$\r$\n$\r$\nClick Next to continue."
 
; Setup installer
  Name       "${MAP_DESC_NAME}"
  OutFile    ${EXE_FILE}
  InstallDir "$PROGRAMFILES\${MAP_SHORT_NAME}"
  BrandingText " "

;--------------------------------
;Interface Settings
;--------------------------------
  !define MUI_ABORTWARNING
;  !define MUI_ICON   ${INSTALL_ICON}
;  !define MUI_UNICON ${INSTALL_ICON}

;--------------------------------
;Pages
;--------------------------------
; Generic welcome screen (optional)
;  !define MUI_WELCOMEFINISHPAGE_BITMAP ${INSTALL_IMAGE}
;  !insertmacro MUI_PAGE_WELCOME

; Custom welcome screen (optional)
  !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${MAP_DESC_NAME} Setup Wizard"
  !define MUI_WELCOMEPAGE_TEXT "${INSTALL_MSG}"
  !insertmacro MUI_PAGE_WELCOME

;  !define MUI_LICENSEPAGE_CHECKBOX
;  !insertmacro MUI_PAGE_LICENSE "${INSTALL_LICENSE}"

; Installation directory dialog
  !insertmacro MUI_PAGE_DIRECTORY

; Installation
  !insertmacro MUI_PAGE_INSTFILES
  
; Readme (optional)
;  !define MUI_FINISHPAGE_SHOWREADME "${INSTALL_README}"
  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
;--------------------------------
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
; The stuff to install
;--------------------------------
Section "Install"
;remove the old version first
  ReadRegStr $R0 HKLM \
  "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" \
  "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  "${MAP_DESC_NAME} is already installed. $\n$\nClick `OK` to remove the \
  previous version and upgrade or `Cancel` to cancel this upgrade." \
  IDOK uninst
  Abort
 
;Run the uninstaller
uninst:
  ClearErrors
  ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 
  IfErrors no_remove_uninstaller
    ;You can either use Delete /REBOOTOK in the uninstaller or add some code
    ;here to remove the uninstaller. Use a registry key to check
    ;whether the user has chosen to uninstall. If you are using an uninstaller
    ;components page, make sure all sections are uninstalled.
  no_remove_uninstaller:
 
done:
; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
; Source files for creating installation
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.tdb"
  File /a "${DIRECTORY}${MAP_SHORT_NAME}.img"
;  File /a "..\garmin\types\${MAP_TYPE}.typ"    ; only if using custom type
;  File /a ".\readme.txt"
  File /a "${DIRECTORY}*.img"

  ;*****************************************************************************************************************
  ;This part determines if the OS is 32 or 64 bit and executes the needed function
  ;*****************************************************************************************************************
  StrCpy $0 0
  ClearErrors ; reset error flags
  IfFileExists C:\Windows\SysWOW64\*.* +1 +3 ;check for folder that only occurs on 64 bit systems
  Call .win7 ; if folder is there call the 64 bit function
  Goto fin   ; move to Label fin:
  Call .winxp ; if folder is not there call the 32 bit function
  
  fin: ;ends section after 64 bit reg entries are written
 
  ;*****************************************************************************************************************
SectionEnd

;--------------------------------
; Uninstaller
;--------------------------------
Section "Uninstall"

; Remove registry keys
  DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\${MAP_SHORT_NAME}"
  DeleteRegKey HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"

; Remove files and uninstaller
  Delete $INSTDIR\*.*
  Delete $INSTDIR\uninstall.exe

; Remove directories used
  RMDir "$INSTDIR"
  
SectionEnd

;*************************FUNCTIONS********************************************
;******************************************************************************
;****************This function writes the 64 Bit registry entries**************
;******************************************************************************
Function .win7

 ; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
;  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Wow6432Node\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
  
   FunctionEnd
  
;******************************************************************************
;****************This function writes the 32 Bit registry entries**************
;******************************************************************************
Function .winxp

 ; Write the installation path into the registry
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Install_Dir" "$INSTDIR"
  WriteRegStr   HKLM "SOFTWARE\${MAP_SHORT_NAME}" "Version"     "${MAP_VERSION}"

; Write the MapSource configuration into the registry
  WriteRegBin   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "ID"    ${MAP_ID}
;  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}"   "TYP"   "$INSTDIR\${MAP_TYPE}.typ"     ; only if using custom type

  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "LOC"   "$INSTDIR\"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "BMAP"  "$INSTDIR\${MAP_SHORT_NAME}.img"
  WriteRegStr   HKLM "SOFTWARE\Garmin\MapSource\Families\${MAP_SHORT_NAME}\1" "TDB"   "$INSTDIR\${MAP_SHORT_NAME}.tdb"

; Write the uninstall keys for Windows
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "DisplayName"     "${MAP_DESC_NAME}"
  WriteRegStr   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe"
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoModify" 1
  WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${MAP_SHORT_NAME}" "NoRepair" 1

  WriteUninstaller "uninstall.exe"
 
Functionend
;**********************************************
« Last Edit: March 05, 2010, 04:48:43 AM by freecat »

-Oz-

  • Map Maker!
  • Administrator
  • Expert Advisor
  • *****
  • Posts: 1579
  • Karma: 27
    • View Profile
    • GPSFileDepot
Re: Problem with NSIS and registry entries
« Reply #13 on: March 01, 2010, 09:32:14 PM »
http://www.gpsfiledepot.com/tools/map_install.zip

That is what is linked to from the tutorial so I've put yours in place of it.

I'll get to test it tomorrow hopefully on my new map.  I just wonder why it worked on my w7-64 with no issues...
Dan Blomberg
Administrator - GPSFileDepot
GPS Units: Garmin Dakota 20, Garmin GPSMap 60csx, Nuvi 255W, Nuvi 250W, ForeRunner 110, Fenix 2, Tactix Bravo, Foretrex 401
See/Download My Maps!

freecat

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Problem with NSIS and registry entries
« Reply #14 on: March 02, 2010, 04:45:46 AM »
Hi Oz
I think the reason that the installer worked for you is that NSIS has a way to check the bit type of the OS and then make changes to the registry part of the installer based on this. From what I have read this is a very buggy feature and rarely works right. Several developers have made plug-ins  to check the OS and bit type and return a string to get around this bug but I think the way I did it will be fine to.
Let me know how your test go and if I need to make any changes to the script.
Thanks
freecat

 

anything