Archive: Writing to the registry fails


Writing to the registry fails
I am using/testing the script below, so far I cant get it to write data to the uninstall section of the Windows registry. It should show me XXX I believe but nothing gets added to that section of the registry.

My account has admin rights.....

Script->>>>>>

;Setup program

;--------------------------------
;Include Modern UI

!include "MUI.nsh"

;--------------------------------
;General

;Name and file
Name "XXX YYY"
OutFile "Setup.exe"

;Default installation folder
InstallDir "$EXEDIR"

;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\XXX\YYY\Uninstall" ""

BrandingText /TRIMLEFT "XXXYYY Setup"

XPStyle on


;--------------------------------
;Interface Configuration

!define MUI_ICON setup.ico
!define MUI_UNICON setup.ico

!define MUI_ABORTWARNING

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP header.bmp
!define MUI_WELCOMEFINISHPAGE_BITMAP welcome.bmp

XPStyle on


;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "Standard installation" StandardInstall

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

;Store installation folder
WriteRegStr HKCU "Software\XXX\YYY" "" $INSTDIR

;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\" "XXX" "YYY"



SectionEnd

;--------------------------------
;Descriptions

;Language strings
LangString DESC_StandardInstall ${LANG_ENGLISH} "Standard installation."

;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${StandardInstall} $(DESC_StandardInstall)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

;ADD YOUR OWN FILES HERE...

Delete "$INSTDIR\Uninstall.exe"

RMDir "$INSTDIR"

DeleteRegKey /ifempty HKCU "Software\XXX"

DeleteRegKey /ifempty HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\XXX"

SectionEnd

;--------------------------------
;Init Section

Function .onInit
SetOutPath $TEMP
File /oname=spltmp.bmp "splash.bmp"

; optional
; File /oname=spltmp.wav "splash.wav"

splash::show 1000 $TEMP\spltmp

Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normal, and '-1' if some error occured.

Delete $TEMP\spltmp.bmp
; Delete $TEMP\spltmp.wav
FunctionEnd


here:


InstallDirRegKey HKCU "Software\XXX\YYY\Uninstall" ""

Where is allocated the returning var???

That's why:

InstallDirRegKey $0 HKCU "Software\XXX\YYY\Uninstall" ""

If I remember. :)

Originally posted by Lobo Lunar
here:

InstallDirRegKey HKCU "Software\XXX\YYY\Uninstall" ""

Where is allocated the returning var???

That's why:

InstallDirRegKey $0 HKCU "Software\XXX\YYY\Uninstall" ""

If I remember. :)
Hmm I'll check it.

I found the method on the NSIS archive and it didn't mention using a var, oh well. Thanks.

Originally posted by Lobo Lunar
here:

InstallDirRegKey HKCU "Software\XXX\YYY\Uninstall" ""

Where is allocated the returning var???

That's why:

InstallDirRegKey $0 HKCU "Software\XXX\YYY\Uninstall" ""

If I remember. :)
Just noticed you were refering to something else which works.

The problem is this line below, it doesn't yield a new data entry within the registry:

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\" "XXX" "YYY"

Of course is only for example propuse :D

You do the real stuff :D