Archive: Writing to HKLM in Vista


Writing to HKLM in Vista
Hello everyone,

i try writing to HKLM\Software\...... with one of my installers, i have defined

RequestExecutionLevel admin


but it does not work, UAC is disabled on my machine.

Anyone know a quick workaround?

Btw. here is what i use to test


; example1.nsi
;
; This script is perhaps one of the simplest NSIs you can make. All of the
; optional settings are left to their default settings. The installer simply
; prompts the user asking them where to install, and drops a copy of example1.nsi
; there.

;--------------------------------

; The name of the installer
Name "Example1"

; The file to write
OutFile "example1.exe"

; The default installation directory
InstallDir $DESKTOP\Example1

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

Page directory
Page instfiles

;--------------------------------

; The stuff to install
Section "" ;No components page, name is not important

; Set output path to the installation directory.
SetOutPath $INSTDIR

; Put file there
File example1.nsi

WriteRegStr HKLM "Software\My Company\My Software" "String Value" "dead beef"


SectionEnd ; end the section


Thanks in advance
xBarns

Call IsUserAdmin in your .onInit.


Well just so i can say i have done it, i have done that, it confirmed that the logged on user is an Administrator, but it still cannot write to HKLM\Software.....

Any other ideas?


This is a bug in vista, when UAC is off and you are running as non-admin, elevation does not work. So you can check in oninit and display a message, or you can use the UAC plugin to elevate, it has built in manual elevation to work around this bug


This is a bug in vista, when UAC is off and you are running as non-admin, elevation does not work.
UAC is off but I AM an admin.

Do you have in your sections the following?

SetShellVarContext all

Do you have in your sections the following? quote:SetShellVarContext all
for writing to the registry ?

If you are admin, nothing should be stopping you from writing to HKLM, you could try Process Monitor from sysinternals and see if it gives you any clues (ERROR_ACCESS_DENIED etc)


Wow, thanks for the tip, i now know where it writes my entries, it seems since i am on a Vista 64-bit Machine that it "reflects" registry entries from 32-bit apps to:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\My Company\My Software

and here MS says why:

http://support.microsoft.com/?scid=k...5097&x=15&y=19

Nice to know, but that redirector seems to work, at least it reads from there also without any manual intervention.


SetRegView might be of help