Archive: EnumRegKey fails for non-admin users


EnumRegKey fails for non-admin users
I don't know if this is the right place to report bugs, but I didn't find any other way to report bugs on the NSIS page at Nullsoft.

Anyway, if I use the EnumRegKey instruction in an installer, and run the installer on Windows NT (and I suppose Windows 2000/XP as well), the instruction will fail.

Looking into the source code in exehead/exec.c, I saw that the registry was opened with all access. By changing the access from KEY_ALL_ACCESS to KEY_READ, everything worked OK.

Here is a diff of the change:

1094c1094
< if (RegOpenKeyEx((HKEY)parms[1],buf2,0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS)
---
> if (RegOpenKeyEx((HKEY)parms[1],buf2,0,KEY_READ,&key) == ERROR_SUCCESS)

It would be great if this correction could make into the official NSIS distribution, as NSIS apart from this little problem is exactly what I needed. I would prefer to not keep my own branch of NSIS.

/Bjorn Gustavsson

P.S. In case you are interested, you'll find my application at http://www.wings3d.com. It is an open-source 3D-modeller.


I'm using EnumRegVal and it works fine for me on the 2000 machines around here. We all have administrator level access, though. I can try seeing what happens if you try without that, but as I said it's EnumRegVal and not Key.

Hope that helps.