![]() |
Get last InstallDir - problem
Hello
NSIS have a very good documentation, in fact the best i have ever seen in a freeware tool. I made an installer script and it worked so far, but i tried to insert an exist check of previously installed versions of my program. I want to determine where it was installed and use that directory as the default output directory at the Install Page. So i let the installer write the used InstallDir into the registry (no problem there). The installer should look at the start, for the regkey that is written by previously installations. btw. I realised that the "Goto" thingie does not realy work like the Windows Batch "Goto". When ther there are 2 identical variables to define, the compiler exits with an error, even if is jumped with a "GOTO"! :( ... but this is another story. Here is the part of the script that does not work: (everything above the CALL is OK!) PHP Code:
The setup is OK but the compiler finish with a warning: 1 warning: LangString "TARGETDIR" is not set in language table of language English 1. Question: what is the connection of this Function and the "language table of language English" ? The Setup starts correctly. -at the first time the InstallDir is empty. -the second time, the Windows Title (caption) got the the $(targetdir) of the previous installation (=>MyPROGRAM - "C:\Program Files\xyz"), and the "InstallDir" @ the InstallPage is empty, too! What went wrong? I tried another way: When i change "Function alreadyexistcheckfunktion" to "Function .onGUIInit" the compiler exits with: PHP Code:
2. Question: What does this function have to do with the macro at all? Isnt it alowed to use the ".onGUIInit" in the main .nsi file?? 3. Question: Why does the window title change into the InstallDir and the default install page is empty? I would be very thankful for any help! bye |
You are mixing compile time defines with run time variables and langstrings and whatnot:
Defines (compile time): !define foo "bar" MessageBox mb_ok ${foo} Variables (run time): StrCpy $0 "bar" MessageBox mb_ok $0 and $(foo) would be a langstring, they are created at compile time, but "selected" in .onInit and are valid after .onInit Lucky for you there is a installer attribute called InstallDirRegKey that will set $instdir to a value from the registry with InstallDir as its backup value if not found Modern UI already uses .onGuiInit for its own internal handling, check the MUI docs, there is a define you can set so it calls your own private onGuiInit like function |
You're confusing compiletime and runtime functions:
PHP Code:
Edit: High-five Anders :) |
omg, that was an easy one :)
thanks for the hint! i add the line and removed some stupid ones from my "alreadyexistcheckfunktion" Function and everything is fine. InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProgram" "InstallPath" thank you! |
| All times are GMT. The time now is 17:40. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.