Archive: Strange error with EnumRegValue in Windows Server 2003 R2


Strange error with EnumRegValue in Windows Server 2003 R2
I am using the following code (I took from somewhere/someone in the NSIS site) to get the ms.net framework v2 folder:

        Exch $R0 ; Set R0 has "v2.0" in it
Push $R1
Push $R2

;This next line prints OK
DetailPrint "Searching for Microsoft.net $R0"

; set R1 to minor version number of the installed .NET runtime
EnumRegValue $R1 HKLM \
"Software\Microsoft\.NetFramework\policy\$R0" 0
IfErrors getdotnetdir_err

DetailPrint "Searching for Microsoft.net $R0 build $R1"

; set R2 to .NET install dir root
ReadRegStr $R2 HKLM \
"Software\Microsoft\.NetFramework" "InstallRoot"
IfErrors getdotnetdir_err

DetailPrint "Root folder found: $R2"
DetailPrint "Found folder: $R2$R0.$R1"

; set R0 to the .NET install dir full
StrCpy $R0 "$R2$R0.$R1"

getdotnetdir_end:
Pop $R2
Pop $R1
Exch $R0 ; return .net install dir full
Return

getdotnetdir_err:
DetailPrint "Where were we? $R2$R0.$R1"
StrCpy $R0 ""
Goto getdotnetdir_end


The result in Windows Server 2003 R2 is always
"Searching for Microsoft.net v2.0
Where were we? 1v2.0.50727"

So it seems like EnumRegValue returns an error in spite of also returnin the correct key name ("50727").

I changed it to this, in order to get it working:
        
; set R1 to minor version number of the installed .NET runtime
EnumRegValue $R1 HKLM \
"Software\Microsoft\.NetFramework\policy\$R0" 0
StrCmp $R1 "" getdotnetdir_err

DetailPrint "Searching for Microsoft.net $R0 build $R1"
ClearErrors


DO you have any idea why this behaviour?

Thanks for your help.
Joel

Could you run process monitor from MS/sysinternals and see if anything pops out at you?