marcins
11th August 2011 12:02 UTC
Write registry key to HKEY_CURRNET_USER from RunAs Admin installer
Hello,
I was looking for this a few days and I still don't know how to do this, so maybe someone here can help me!
I have installer that must be run as Admin to copy all files into right directories but at same time I need to write registry key to HKEY_CURRNET_USER (can be all users in the system, doesn't matter). But when I'll run installer as Admin it will write registry key (only) to Admin's HKEY_CURRNET_USER, not user that I want.
So is there any way/script to write something for HKEY_CURRENT_USER to all users in system?
HKEY_LOCAL_MACHINE is not good for me... must be HKEY_CURRENT_USER.
MSG
11th August 2011 14:14 UTC
You can user enumusersreg to get access to all trees in the HKU hive. If you only want access to the user who first executed the installer, you'll need the UAC plugin (not recommended).
Note however that you should not write to userlevel registry in an admin-only installer. If an installer requires admin access, it should always install for all users, and thus should write to HKLM. Only userlevel installers are supposed to install for a single user. This is the way Windows is designed to be used.
marcins
16th August 2011 09:27 UTC
Well it doesn't work like that to me. Can someone please help me?
When I run it on Admin account scripts add lines to registry but only for Admin.
Here is simple script that i want to use.
!include "EnumUsersReg.nsh"
Name EnumUsersReg
OutFile EnumUsersReg.exe
ShowInstDetails show
Section
; use ${un.EnumUsersReg} in uninstaller sections
${EnumUsersReg} CallbackFunction temp.key
SectionEnd
Function CallbackFunction
Pop $0
; registry x32
WriteRegStr HKU "Software\JavaSoft\Prefs\com\ibm\/S/P/S/S\/S/P/S/S /Statistics\19.0\ui\doc_types\dataeditor\menus\19;/Predictive /Solutions;0;;\0;/P/S /D/A/S;0;;" "0" "separator;"
WriteRegStr HKU "Software\JavaSoft\Prefs\com\ibm\/S/P/S/S\/S/P/S/S /Statistics\19.0\ui\doc_types\output\menus\19;/Predictive /Solutions;0;;\0;/P/S /D/A/S;0;;" "0" "separator;"
WriteRegStr HKU "Software\JavaSoft\Prefs\com\ibm\/S/P/S/S\/S/P/S/S /Statistics\19.0\ui\doc_types\syntax\menus\19;/Predictive /Solutions;0;;\0;/P/S /D/A/S;0;;" "0" "separator;"
DetailPrint $0
FunctionEnd
Anders
16th August 2011 17:30 UTC
Software is not the the root of HKU
marcins
16th August 2011 19:53 UTC
So how i should write that Key? I cant use numbers like S-1-5-21... because they are different in every windows?! Please help!
Anders
16th August 2011 21:39 UTC
Originally posted by marcins
So how i should write that Key? I cant use numbers like S-1-5-21... because they are different in every windows?! Please help!
EnumUsersReg knows
msroboto
16th August 2011 21:47 UTC
I know you say that you have to write this for every user.
How will you handle new users added to the system after your install?
Just something to consider.
Anders
17th August 2011 03:33 UTC
Originally posted by msroboto
I know you say that you have to write this for every user.
How will you handle new users added to the system after your install?
Just something to consider.
The correct way to handle this is to copy default settings to HKCU when your _application_ is started for the first time as that user
marcins
17th August 2011 09:02 UTC
Ok its working now! I forgot to put $0\ before Software. Thanks for help!