Old 27th June 2007, 13:45   #1
nashirak
Junior Member
 
Join Date: Jun 2007
Posts: 3
Multiple User Priv. Install

Hi,

I am trying to create an installer that is capable of installing any registry items to either HKLM or HKCU (maybe others down the road). I am aware I could, (everywhere I write to a registry) do something like:

StrCmp $local_machine '1' total_machine
DeleteRegKey HKCU "${PRODUCT_UNIST_KEY}"
Goto skip_total
total_machine:
DeleteRegKey HKLM "${PRODUCT_UNIST_KEY}"
skip_total:

Where $local_machine was a variable populated by a MessageBox response, but I am looking for a cleaner solution. I have tried something like:

DeleteRegKey $local_machine "${PRODUCT_UNIST_KEY}"

Where $local_machine was a variable that contained HKLM or HKCU but I quickly found that those were actually integer like values. Is there a clean way to do the code located above or am I going to have to bite the bullet and do the equivalent of large if/else blocks (in this case goto blocks). Sorry if there is a simple answer to this question as I am new to NSIS.
nashirak is offline   Reply With Quote
Old 27th June 2007, 13:52   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Use SHCTX instead of HKCU and HKLM. It changes to either HKCU or HKLM according to SetShellVarContext.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th June 2007, 14:23   #3
nashirak
Junior Member
 
Join Date: Jun 2007
Posts: 3
Thanks for the response, this works for all the Registry Writes and Deletes, but not for the initial:

InstallDirRegKey SHCTX "${PRODUCT_DIR_REGKEY}"

Since I am to able to use StrCmp outside of a function, and InstallDirRegKey requires that you use it outside of a function I am at a loss as to what should be done.

Any other suggestions?
nashirak is offline   Reply With Quote
Old 27th June 2007, 14:40   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can do that manually in .onInit.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th June 2007, 15:13   #5
nashirak
Junior Member
 
Join Date: Jun 2007
Posts: 3
I am not quite sure what you mean by "manually" install. I cannot put

InstallDirRegKey

inside on .onInit because that is a function. Is there some directory I should set my path to create this "manually" or something?? Some example code or a pointer to a project that has done what you are describing would be great.

Thanks.
nashirak is offline   Reply With Quote
Old 27th June 2007, 15:17   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Manually read the registry using SHCTX in .onInit using ReadRegStr. You can't use SHCTX in InstallDirRegKey because you'd have no where to call SetShellVarContext prior to the parsing of InstallDirRegKey. $INSTDIR is set according to InstallDir and InstallDirRegKey before .onInit is called. .onInit is always the very first piece of code of your script called.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump