Archive: How can I found the install path of a Programm


How can I found the install path of a Programm
Hy

I've build an Extension (with Multiplayer) for my game (Gta Vice City). But now I must find the Installdir of it also If it exist on the computer D:\Games\GTA VC and if it not exist C:\Games\Extension\GTA VC

How can I do this ?

Thank you


You can check with:

IfFileExists "D:\Games\GTA VC\*.*" 0 +3
StrCpy $INSTDIR "D:\Games\GTA VC"
Goto done

IfFileExists "C:\Games\Extension\GTA VC\*.*" 0 +2
StrCpy $INSTDIR "C:\Games\Extension\GTA VC"

done:


However, this isn't a very good way to go about it. The user may have installed to Program Files ($PROGRAMFILES) or maybe even E:\
Your best bet is to look for a registry entry which contains the game's path by using ReadRegStr.

-Stu

Thank you for answer me. Yes there is an RegStr is it right so ?

ReadRegStr $0 HKLM Software\Rockstar-Games\GTA Vice City "InstallPath"
StrCpy $0 $INSTDIR ""
done:


Or just do:


ReadRegStr $INSTDIR HKLM Software\Rockstar-Games\GTA Vice City "InstallPath"
StrCmp $INSTDIR "" 0 +2
StrCpy $INSTDIR "C:\GTA VC"


-Stu

Thank you for the reply.

But I've an other question:

The code:


ReadRegStr $0 HKLM Software\Rockstar-Games\GTA Vice City "InstallPath"
StrCpy $0 $INSTDIR ""
done:


must be in a Function ?

Example: Function Path

And on the top I write call Path.

But there is an Error because I can't exec the Installer.

Thx Marc

Even outside a function or section you easely could use

InstallDir "C:\GTA Vice City"
InstallDirRegKey HKLM Software\Rockstar-Games\GTA Vice City "InstallPath"


Thats all you need. If a valid registry string was found the new InstallDir is set otherwise it falls back to the previous value.

Thank you that's it