- NSIS Discussion
- read key and action if have a value
Archive: read key and action if have a value
moxo
29th July 2003 11:10 UTC
read key and action if have a value
i have a product in two part, i can install separately in two computer but if i install on same computer, in install section i need to read a key read said me the path where one of my part had installed and after i use this path in directory page of install. If this key is not present i use the path by default.
my problem is: i don't know use the function if in NSIS.
my key
ReadRegStr HKCU "Software\${MUI_PRODUCT}\part1" "" ${pathpart1}
and if not present, i want to use InstallDir "$PROGRAMFILES\${MUI_PRODUCT}
i have the same problem in uninstall section a want to read a key, if a key is present i don't want delete the main folder, and if is not present i want to call a fonction who uninstall another product.
thanks for your help
Vytautas
29th July 2003 13:40 UTC
Not exacly certain about the uninstall part but as for the installer you should first set the $INSTDIR to the path you want to use if the other part is not installed and then use the 'InstallDirRegKey' command to overwrite the path if the specified key exists.
Vytautas
Afrow UK
29th July 2003 13:42 UTC
Well, firstly you set InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
Now,
ReadRegStr $R0 HKCU "Software\${MUI_PRODUCT}\part1" "" ${pathpart1}
StrCmp $R0 "" +2
StrCpy $INSTDIR $R0
Is this what you want?
-Stu
Vytautas
29th July 2003 13:45 UTC
Afrow UK, is it not easier to use 'InstallDirRegKey' function?
Vytautas
moxo
29th July 2003 16:09 UTC
thanks for your help
i 'm trying and i said you tomorrow what solution i used.
moxo
30th July 2003 13:07 UTC
i try this
ReadRegStr $R5 HKCU "Software\${MUI_PRODUCT}" "Pathproduct"
IfErrors 0 suite
InstallDir "$R5"
Goto next
suite:
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
goto next
next:
InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" ""
i have this error
Can't add entry, no section or function is open!
so i add this in function .oninit
now i have error
command InstallDir not valid in function.
How can i put the path what i store in registry with previous install in directory page.
i thinks i have done a bad explication.
in my product i have to part in one side i have the client and the other side i have the server. i can install server and clietn in same computer or in separately computers.
my client side is installed in a sub folder "client" (for server it s in a subfolder "server". the main folder is the product folder.
I want when i install for example my client side to put a registry key who said me where are my product, like: HKCU "Software\${MUI_PRODUCT}" "Pathproduct"
and other key with my path client like
HKCU "Software\${MUI_PRODUCT}\Client" "PathClient" in this key i have
PathProduct\client (i thinks is more easy for updtade)
Now if i install server side (or client side for update).
i want my install check if this key exist HKCU "Software\${MUI_PRODUCT}" "Pathproduct"
in directory page i want it propose the path of product and after the serverside is installed in subfoler server.
but if this key doesn't exist, the directory page propose me the default path $PROGRAMFILES\${MUI_PRODUCT}.
i hope now i have done a good explication :)
thanks
Afrow UK
30th July 2003 13:14 UTC
Your stuff needs to go into a section/function.
e.g. use onInit to execute your cmds on initialisation
Function .onInit
ReadRegStr $R5 HKCU "Software\${MUI_PRODUCT}" "Pathproduct"
IfErrors 0 suite
InstallDir "$R5"
Goto next
suite:
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
goto next
next:
InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" ""
FunctionEnd
-Stu
Vytautas
30th July 2003 13:37 UTC
InstallDir won't work in a function to assign a path inside a function you sould use
StrCpy $INSTDIR "your_path"
Vytautas
moxo
30th July 2003 14:58 UTC
InstallDirRegKey won't work in a function.
i tried the function but i don't use InstallDirRegKey.
in my first installation, in directory page, by defalut i have :
c:\program files\myproduct.
i choose, c:\bin\myproduct. my product(serverside) is installed in c:\bin\myproduct\server.
now if i install again server side of if i install the first installation of client side, in directory page i have again
c:\program files\myproduct and no c:\bin\myproduct.
why doctor???
thanks
Afrow UK
30th July 2003 15:25 UTC
You will have to make your own registry key to store the InstallDir value, instead of using InstDirRegKey.
-Stu
moxo
30th July 2003 16:25 UTC
in the install, i had created
!define pathsrv "$INSTDIR\server"
WriteRegStr HKCU "Software\${MUI_PRODUCT}" "Pathproduct" $INSTDIR
and
WriteRegStr HKCU "Software\${MUI_PRODUCT}\server" "" ${pathsrv}
and for me the $INSTDIR is the path i have define in directory page in the first time.
but it's no good
Afrow UK
30th July 2003 16:31 UTC
Can you post your script so I can understand what you are trying to achieve?
-Stu
moxo
31st July 2003 09:59 UTC
in the client side, only this variable change
MUI_PRODUCT = client
MUI_VERSION = v2.0
FOLD_INST = client
PATH_SRV = $INSTDIR\${FOLD_INST}
so i have two problem when i install the client side(or for update server side) i want the program go to read if regkey HKCU "Software\${COMPANY}" "PathComp" exist and if is good i want the directory page show me the value of this key (it's the $INSTDIR of first install) and if is not good directory page show me $PROGRAMFILES\${COMPANY}.
my other problem is uninstall, i have noticed the directory page of unistallation show me the path ${PATH_SRV}\${FOLD_INST}, so i have for example c:\program files\my company\server\server and i want c:\program files\my company\server.
thanks
Afrow UK
31st July 2003 10:35 UTC
Ok, heres what should be done [from what I have read].
Use in uninstall section.
ReadRegStr $R0 HKCU "Software\${COMPANY}" "PathComp"
StrCmp $R0 "" 0 is_present ;jump to
ReadRegStr $R0 HKCU "Software\${COMPANY}\${FOLD_INST}" "PathSrv"
## do stuff here for non present reg entry ##
Goto done
is_present:
## do stuff here for presnt reg entry ##
done:
I noticed this should be changed:
execwait '$SYSDIR\msiexec.Exe /i $EXEDIR\access-2000\osp.msi TRANSFORMS="$EXEDIR\access-2000\osp.MST" /qb-'
to
ExecWait '"$SYSDIR\msiexec.exe" /i "$EXEDIR\access-2000\osp.msi" TRANSFORMS="$EXEDIR\access-2000\osp.MST" /qb-'
Else, this execute would fail if $SYSDIR or $INSTDIR had spaces in it.
-Stu
moxo
31st July 2003 13:16 UTC
thanks a lot for your help.
i hope to help you one day.