|
|
#1 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Writing and reading from the same reg key
Hello,
I haven't found a thread that describes the same issue that I'm having, therefor I will try to detail my problem as much as I can. I've created an installer which will read a certain registry key and, after "parsing" it with StrCpy, it will write it in another registry key. When the installer ends (.onGUIEnd) that new created registry key will be deleted; so it will act as a temporary registry key. The problem that I've encounter is that the installer doesn't read the new written registry key. The following code will write the temporary registry key without any problem. code: Now, if I want to get that key and make it the installation directory, it won't be able to read it. code: The above code-line will only work if the installer is reopened and the temporarily registry key is not deleted upon closing. My question is: How can I write and read the same registry key in the same installation process? Looking forward to your reply. |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,841
|
As far as I know, the InstallDirRegKey is read before the installer even starts. It's like an automatic "ReadRegStr $INSTDIR Hive Path Key" command in .onInit. What you'll need to do is do it manually, after the key is created. (But seriously, why on earth would you want to do that? Just StrCpy $INSTDIR "${something}" would suffice...)
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Hello,
Thank you for the fast reply. At first I tried that but unfortunately, by the time I ended up in the Directory Page, the $INSTDIR was empty. I tried using global variables and even !define to get that key stored after ReadRegStr but every time the Function .... FunctionEnd passed that variable became "unset" |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,841
|
I'm pretty sure there's absolutely no problem with reading a regstr you created in earlier. If your $INSTDIR is empty, there's a problem in your script. Use MessageBox etc to find the problem (specifically, check the location of the regstr you're telling it to read/write).
Also: ALL variables in NSIS are global. There are no local variables. |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Oct 2007
Location: Xi'an, China
Posts: 194
|
!define is a compiling command, whether use it or not is the same.
You need to find out the origin of your problem. An NSIS fan from China, my name is Jia Ke (pinyin). Email: jiake@vip.qq.com Messenger: jiake@live.in QQ (Chinese IM): 550771955 |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Hello,
Thank you for the replies. I've tried creating a simple example to show the issue I'm having. Testing it will have the same result. code: When the installer is open, the key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Stuff TMP\TMPPath" exists but, regardless where I put the InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Stuff TMP" "TMPPath" line, it won't fill in the path. PS: The messagebox shows the path correctly the problem is setting the InstallDir with that variable. |
|
|
|
|
|
#7 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,841
|
Like I said, you'll need to ReadRegStr MANUALLY. Don't use InstallDirRegKey.
|
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Hello,
Ok, I changed it to ReadRegStr when the Directory Page is shown but nothing seems to be changed. code: |
|
|
|
|
|
#9 |
|
Major Dude
Join Date: Oct 2006
Posts: 1,841
|
First of all, you DO have administrator access when you run this test installer, right? >__>
Other tips: - Reading the written regstring is still entirely pointless. Just use the variable containing the path directly! - $trim_path is unneeded, just use StrCpy $path $path 23. Saves one variable. - Why trim the first 23 characters? If I installed winamp to c:\foobar, the trim result will be entirely different from when I installed to c:\Program Files (x86)\Multimedia\z0mglongpath\winamp... |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Hello,
I will reply to your message in the same order: 0. Yes, I'm running as Administrator. 1. I've tried that as well (at the first time I've created the script) but it didn't worked so I guessed that I need to save it somewhere and read it back. 2. Point taken. 3. I've trimmed that because in the registry, under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winamp\DisplayIcon you will find something like "C:\Program Files\Winamp\winamp.exe,0". I've trim it to get a folder of an already installed application. After getting that path I could easily modify it according to my needs adding somethig like "$already_installed_application\plugins" folder that can't be found in the registry or anywhere else. I tried now something, based on your idea and I finally managed to get it to work. It seems that I need to set the $INSTDIR before the CUSTOMFUNCTION_SHOW. I guess my previous testing was made using it in that function. Thank you for all your help and for bearing with me. |
|
|
|
|
|
#11 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
|
Why would you trim to 23 characters? That will only work when the path starts with C:\Program Files\Winamp in which case, what is the point of reading the path in the first place?
This is what you want: Stucode: Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Sep 2008
Posts: 16
|
Hello,
Thank you for the idea, Stu. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|