PDA

View Full Version : Combine INSTALLPATH



Leones
09-14-2004, 05:28 AM
Hello,

I've got some trouble with the installpath and hope somebody can me help out of this.

My case:

I should get a value out of a registrykey, which is only a word, for example "Meier". The installer should get the registryvalue and install the programm in the programmfiles folder in the folder "Meier".

So I tried out to set the [INSTALLDIR] =

[ProgramFilesFolder]^HKEY_LOCAL_MACHINE\SOFTWARE\AppData\RegFoldername

Isn't it possible to combine a registryvalue with an hardcodepath?

I couldn't find a solution..

Thanks for any help,

Léon

Mike Marino
09-20-2004, 09:30 PM
You cannot set the INSTALLDIR property like you are trying to do. Here is how to do what you want:

1. Set INSTALLDIR back to the default value you want without the Registry Key appended to it.
2. Go to the Requirements view (Under #5)
3. Right Click on System Software Requirements
4. Select "Create New..."
5. Click Next.
6. Select "Registry Entry". Click Next.
7 Enter the Registry entry you want to look for. For example, I am looking for

HKEY_LOCAL_MACHINE\SOFTWARE\InstallShield\Test

Where

DirName = MyDirectory

So I enter:

Registry Root: HKEY_LOCAL_MACHINE
Registry Key: SOFTWARE\InstallShield\Test
Registry Value: DirName

8. Click Next.
9. Enter what you want to do if the Registry Key is not on the system, and a message to display to the user if it is found/not found. If you do not care whether it is found or not see step 11 below.
10. Click Finish.
11. If you do not care whether or not the key is found, click the box in front of the condition you just created until it is empty (no X or Check Mark).

OK, what we just did is create an MSI registry lookup that will lookup the Registry Key and assign it to a property (The Property name is what appears as the Name in the Requirements view).

Next we need to create a custom action to append the INSTALLDIR and the Property you just create (in this example it would be named DIRNAME after the Registry Value I am looking for.)

Open your favorite text editor and write the following VBScript code:

MsgBox Session.TargetPath("INSTALLDIR")
MsgBox Session.Property("DIRNAME")

Session.TargetPath("INSTALLDIR") = Session.TargetPath("INSTALLDIR") + "\" + Session.Property("DIRNAME")

MsgBox Session.TargetPath("INSTALLDIR")

When you run it for real...remove the MsgBox's. They are here so you can see it work.

12. Go to the Custom Action view (Under #5).
13. Right click on "After Initialization" and select New VB Script.
14. Set the File Name to the script file you created above.
15. Build the Setup and run it.....

This should do what you want.

Leones
09-21-2004, 09:37 AM
Yep, that's what I am talking about. Thank you verry much for your description. So I got one more little question left, for this problem:

I've created an VBS like you told me. But I tried to change the
Session.Property("DIRNAME") trought the Registryvalue, so my script looks like this:


Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

Session.TargetPath("INSTALLDIR") = Session.TargetPath("INSTALLDIR") + "\" + WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\DOGREL\test")

MsgBox Session.TargetPath("INSTALLDIR")

But it allways stopps with an error.

I know you gave my allready a excellent solution, but I really need to do it like this.

It would be verry kind of you, if you could help me out of this, again.

Thanks, Léon

Mike Marino
09-21-2004, 02:19 PM
Your code should look like this:

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

Session.TargetPath("INSTALLDIR") = Session.TargetPath("INSTALLDIR") + "\" + WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\DOGREL\test")

MsgBox Session.TargetPath("INSTALLDIR")

Hope this helps.

sanjoygr
03-17-2006, 09:52 AM
Using InstallShield 11 Professional, Basic MSI project.

I want the setup user install the application under a predifine myfixdfolder.
There is option to change the drive but not the folder.
The default seting is [WindowsVolume]\MyFixedFolder. This is design time INSTALLDIR.

The user can change the Drive by cicking the change button of DESTINATION dailog.
In the OK push button of the InstallhangeFolder dialog following events

DOAction , MyCustomActionFolderChange, 1.
SetTargetPath, [_BrowseProperty],1
EndDialog, Return, 1

The custom action have following setting:
VBScriptFile Name:MyFolChng.vbs
ReturnProcessing:Asynchronous (Waits For exit code)
In-Script Execution:Immediate Execution
ExecuteSchedule:Execute Only Once
Use64BitsScripting:NO
and all other is Absent from sequence.

The VB script is as following:

Option Explicit

Dim MyFixFolder,InstallDefaultPath,InstallDefaultFolder,StrCmpFolder
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

MyFixFolder="THRTE_4.7.5\"

InstallDefaultPath =Session.Property("INSTALLDIR")
Msgbox InstallDefaultPath

If len(InstallDefaultPath)>3 Then
InstallDefaultFolder=left(InstallDefaultPath,3)
StrCmpFolder = StrComp(MyFixFolder,InstallDefaultFolder)
If StrCmpFolder <> 0 Then
Session.Property("INSTALLDIR")=Right(InstallDefaultPath,3) & MyFixFolder
End If
Elseif len(InstallDefaultPath)=3 then
Session.Property("INSTALLDIR")=InstallDefaultPath & MyFixFolder
End if

'Change the _BrowseProperty to new value
InstallDefaultPath =Session.Property(_BrowseProperty) &"\"
If len(InstallDefaultPath)>3 Then
InstallDefaultFolder=left(InstallDefaultPath,3)
StrCmpFolder = StrComp(MyFixFolder,InstallDefaultFolder)
If StrCmpFolder <> 0 Then
Session.Property(_BrowseProperty)=Right(InstallDefaultPath,3) & MyFixFolder
End If
Elseif len(InstallDefaultPath)=3 then
Session.Property(_BrowseProperty)=InstallDefaultPath & MyFixFolder
End if

MsgBox Session.Property(_BrowseProperty)
MsgBox Session.TargetPath("TARGETPATH")
MsgBox Session.TargetPath("INSTALLDIR")
WshShell.Quit


While running the script I am geting error :2343 or 2872 on selecting Chhange folder option or On selecting the default setting.

2872-Is for- The argument of the CheckPath control event on dialog [2] is invalid. But I cannot understand this?[/B]
[B]2343 -Is For- Specified path is empty.

Please let me know my mistakes?


Thanks
Sanjoy