- NSIS Discussion
- InstallDirRegKey and ReadRegStr ?
Archive: InstallDirRegKey and ReadRegStr ?
MrRadicalEd
9th October 2003 19:57 UTC
InstallDirRegKey and ReadRegStr ?
Im using the basic script example in the MUI folder, and I tried using the InstallDirRegKey so the installer will use that location for the installation, but it still keeps the file.exe
This is what it looks like:
;Folder selection page
InstallDir $INSTDIR
;Remember install folder
InstallDirRegKey HKCU Software\Valve\Steam SteamExe
After being compiled I test the installation and it spits out location/file.exe read from the registry key. I know I read in the manual that using InstallDirRegKey strips quotes, and the file.exe from the path.
Also I'm not sure if I quite understand how this works, but I'm trying to get individual files installed by different detected registry keys. I know it has something to do with ReadRegStr, but I haven't got the installer to do what I want it to do.
The installer would have separate sections, and each section would be installed to a specific path that was read from a registry key
Components:
[]Core
[]Developer
[]Extra
[]Extra2
Im thinking as a simple beginner and saying that maybe I can do something like this?
Function .onInit
ReadRegStr $1 HKCU "Software\Valve\Steam" SteamExe
ReadRegStr $2 HKCU "Software\Valve\Steam" ModInstallPath
FunctionEnd
Except when you get the path for \HKCU\Software\valve\steam SteamExe, it returns a steam.exe at the end. I only need the path itself.
For every file to install it would look like this:
SetOutPath "$1"
File "${NSISDIR}\Contrib\UIs\modern.exe"
and then all I need the installer to do is make sure the user show that they have an installed component inside say /STEAM, and that the installer would proceed if steam.exe was found.
Joost Verburg
9th October 2003 21:16 UTC
You can use the GetParent function from the documentation.
MrRadicalEd
9th October 2003 21:46 UTC
$1 produces something like "c:\program files\steam\steam.exe"
$2 produces something like "c:\program files\steam\steamapps\user@user\half-life"
So from what I understand.. it would something like this?
Function .onInit
ReadRegStr $1 HKCU "Software\Valve\Steam" SteamExe
ReadRegStr $2 HKCU "Software\Valve\Steam" ModInstallPath
FunctionEnd
Function GetParent
Exch $R0 ; old $R0 is on top of stack
Push $R1
Push $R2
StrCpy $R1 -1
loop:
StrCpy $R2 $R0 1 $R1
StrCmp $R2 "" exit
StrCmp $R2 "\" exit
IntOp $R1 $R1 - 1
Goto loop
exit:
StrCpy $R0 $R0 $R1
Pop $R2
Pop $R1
Exch $R0 ; put $R0 on top of stack, restore $R0 to original value
FunctionEnd
Section ""
Push "$1"
Call GetParent
Pop $R0
SectionEnd
and to use the new path for a file installation I would use $R0 insteald of $1?
deguix
9th October 2003 22:39 UTC
Depend on you. Can push or pop any variable.
MrRadicalEd
9th October 2003 22:49 UTC
I only got that out of the manual, and didn't understand much of it :/
kichik
9th October 2003 23:03 UTC
InstallDirRegKey should strip the EXE part (unless it's a real directory path) and does in my tests. What's the exact string in that registry value you're passing on to InstallDirRegKey?
MrRadicalEd
9th October 2003 23:10 UTC
c:/program files/steam/steam.exe
kichik
9th October 2003 23:14 UTC
No wonder then... That's an invalid path. It uses forward slashes instead of backslashes. If you want to use it, you'd have to process it yourself, replacing every slash with a backward slash to avoid problems and trimming the last part on your own. If you don't want to write something of your own, you can use some of the Archive functions, some of them will surely help.
MrRadicalEd
9th October 2003 23:20 UTC
Alright.. thanks for the info. This installer is going to simplify a rather tricky install of some files for a game, and luckily there is a different registry key that is valid using back slashes..
unfortunately its path is longer than I desire. I found the GetParent documentation in the manual, but I see that you have to define the function before you use it, and I don't completely understand the use of Pop, Push, Exch, and so on
kichik
9th October 2003 23:23 UTC
This Archive page should explain it:
http://nsis.sourceforge.net/archive/...php?pageid=216