I'm running into an issue with my installer on Windows 2003 Server; in regards to the registry. I', an admin user and therefore have complete privileges. If I use regedit i can add a key no probblem, however, if I use the installer which works on all the other windows operating systems, it fails to add any of the registry keys. I'm using a pretty simple macro to do this:
Which you'd call like:
!macro CreateRegVarIfNotExist UPDATE TYPE ROOT KEY NAME VALUE
; Update: 1= Yes, 0 = No
; Type One of: STRING, STRINGEX, DWORD, HEX
push $R0
!define Index 'Line${__LINE__}'
!insertmacro IfKeyExists "${ROOT}" "${KEY}" "${NAME}"
Pop $R0
;$R0 contains 0 (not present) or 1 (present)
IntCmp "$R0" "1" "${Index}-Exists" 0
StrCmp "${TYPE}" "STRING" 0 +3
WriteRegStr "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
StrCmp "${TYPE}" "STRINGEX" 0 +3
WriteRegExpandStr "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
StrCmp "${TYPE}" "DWORD" 0 +3
WriteRegDWord "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
!ifdef _HEXED_
StrCmp "${TYPE}" "HEX" 0 +3
WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
!endif
"${Index}-Exists:"
; update?
IntCmp "${UPDATE}" "0" "${Index}-Done" 0
StrCmp "${TYPE}" "STRING" 0 +3
WriteRegStr "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
StrCmp "${TYPE}" "STRINGEX" 0 +3
WriteRegExpandStr "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
StrCmp "${TYPE}" "DWORD" 0 +3
WriteRegDWord "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
!ifdef _HEXED_
StrCmp "${TYPE}" "HEX" 0 +3
WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
Goto "${Index}-Done"
!endif
"${Index}-Done:"
!undef Index
pop $R0
!macroend
!macro IfKeyExists ROOT MAIN_KEY KEY
push $R0
push $R1
!define IKEIndex 'Line${__LINE__}'
StrCpy $R1 "0"
"${IKEIndex}-Loop:"
; Check for Key
EnumRegKey $R0 ${ROOT} "${MAIN_KEY}" "$R1"
StrCmp $R0 "" "${IKEIndex}-False"
IntOp $R1 $R1 + 1
StrCmp $R0 "${KEY}" "${IKEIndex}-True" "${IKEIndex}-Loop"
"${IKEIndex}-True:"
;Return 1 if found
push "1"
goto "${IKEIndex}-End"
"${IKEIndex}-False:"
;Return 0 if not found
push "0"
goto "${IKEIndex}-End"
"${IKEIndex}-End:"
!undef IKEIndex
exch 2
pop $R0
pop $R1
!macroend
Anyone have any ideas as to why I'm unable to add registry keys?
; ODBC Driver
!insertmacro CreateRegVarIfNotExist 1 "STRING" HKLM "Software\ODBC\ODBCINST.INI\ODBC Drivers" "$(DESC_ODBC_DRIVER)" "Installed"
!insertmacro CreateRegVarIfNotExist 1 "STRING" HKLM "Software\ODBC\ODBCINST.INI\$(DESC_ODBC_DRIVER)" "CPTimeout" "<not pooled>"
!insertmacro CreateRegVarIfNotExist 1 "STRING" HKLM "Software\ODBC\ODBCINST.INI\$(DESC_ODBC_DRIVER)" "Driver" "$INSTDIR\myodbc.dll"
!insertmacro CreateRegVarIfNotExist 1 "STRING" HKLM "Software\ODBC\ODBCINST.INI\$(DESC_ODBC_DRIVER)" "Setup" "$INSTDIR\myodbc.dll"