- NSIS Discussion
- Find the directory in registry to install to?
Archive: Find the directory in registry to install to?
kukomamasan
13th March 2004 16:40 UTC
Find the directory in registry to install to?
Hi im an absolute new to make installers by scripting, what i would like to know is how do you make a section that tells to read i the registry for a location to install too. remember im new, i dont understand any scripting language :-( , though i can read hehe, so found out i need to use readregstr somewhere, how should the line look like, and how do i make the installdir to point to that directory? plz give me an example from the real life :-) , cant translate any of the var_set x+y and thing like that.
would be great if you could even write the whole command on how to read from registry place HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\GhostRecon.exe and under there is a string called path, thats where i would like to make NSIS look and somehow make the string to installdir.
Hope anyone see my problem :-)
Another little thing, how do you add a whole directory containing of several 1000 files and folders? im not gonna add them individualy lol, so far im repacking my stuff to zip and use zip2exe.
thx in advance kuko.
Yathosho
13th March 2004 16:48 UTC
the StripPath function should help you here
kukomamasan
13th March 2004 16:54 UTC
ty for the quick reply, but im new lol cant understand any of the thing that script do, cant even see where it would look for the uninstall reg entry to look for winamp, i need a step by step guide :-( sorry.
atsuk
13th March 2004 17:23 UTC
this reads directory from registry, and returns it inot variable $RegInstDir. later in sections you can use $RegInstDir just like $INSTDIR.
RegInstDir
>Function .oninit
ReadRegStr $RegInstDir HKCU "Software\MyProgram" "Directory"
>FunctionEnd
Section
SetOutPath $RegInstDir
File "c:\\myfile.txt"
>SectionEnd
>
Yathosho
13th March 2004 17:27 UTC
ah, i read something else. depending on the registry entry, either InstallDirRegKey or the above mentioned StripPath should bring you further. i recommend you check the example-scripts in the NSIS directory or in the archive.
kukomamasan
13th March 2004 19:12 UTC
ok thx for the answers, well i found something similar though required alot of testing, but i got it working somehow, looks like this
Function .onInit
Push $INSTDIR ;save compile-time value
ReadRegStr $INSTDIR HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\GhostRecon.exe" path
StrCmp $INSTDIR "" 0 +2
Pop $INSTDIR ;return compile-time value
FunctionEnd
so thats the first part :-) i got it to show d:\ghost recon , now i need to add \mods\ to the $instdir
Joost Verburg
13th March 2004 19:22 UTC
InstallDirRegKey does exactly the same thing.
kukomamasan
13th March 2004 19:42 UTC
Amasing how simpel it can be done :-) jep InstallDirRegKey worked fine for this installer, thx, though i still need to find out how to add \mods\ to the install dir then?
Joost Verburg
13th March 2004 19:46 UTC
Function .onInit
StrCpy $INSTDIR $INSTDIR\mods
FunctionEnd
kukomamasan
13th March 2004 19:59 UTC
Thx now im ready to make some installations :-)
kukomamasan
14th March 2004 00:45 UTC
oh wasent so easy at all :-( i got this so far : Name "${PRODUCT_NAME}"
OutFile "C:\Documents and Settings\admin\Skrivebord\SotoPlasterV4.exe"
InstallDir "$PROGRAMFILES\Red Storm Entertaintment\Ghost Recon\Mods\SotoPlasterv4"
ShowInstDetails show
ShowUnInstDetails show
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\GhostRecon.exe" path
Function .onInit
StrCpy $INSTDIR $INSTDIR\MODS\SotoPlasterV4
FunctionEnd
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File /r "E:\Ghost Recon\mods\SOTOPlasterV4\*.*"
SectionEnd problem is if there is no reference to the path in the registry, the path would look like this C:\Programmer\Red Storm Entertaintment\Ghost Recon\Mods\SotoPlasterv4\MODS\SotoPlasterV4 i guess i should add some check to see if it found a valid directory in the registry, what should that be?
Joost Verburg
14th March 2004 11:45 UTC
That's because you have added
InstallDir "$PROGRAMFILES\Red Storm Entertaintment\Ghost
If you remove that line $INSTDIR will be empty in .onInit if there is no valid path.
kukomamasan
15th March 2004 01:33 UTC
Thx though i have found another solution, and its working, again somehow :-)
Function .onInit
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\GhostRecon.exe" "path"
StrCmp $R0 "" NotPresent Present
notpresent:
StrCpy $INSTDIR "$programfiles\Red Storm Entertainment\Ghost Recon\Mods\SotoPlasterV4"
goto done
present:
strcpy $instdir $R0\mods\SotoPlasterV4
done:
functionend
installdir \SotoPlasterV4
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File /r "E:\Ghost Recon\mods\SOTOPlasterV4\*.*"
SectionEnd