PDA

View Full Version : getting path info from registry?



geoffcox
12-04-2002, 06:03 AM
Hello,

am I right in thinking that v4 will allow me to install an exe file and then later get the path to that file from the registry? This is not possible with ealier versions of ISX?

I need the path to the exe in order to create a shortcut.

Cheers

Geoff

Chandima
12-04-2002, 12:24 PM
I'm afraid Express 4.0 does not support this (it's called "AppPaths" in Developer). I've been pushing this for a while it keeps getting left out.

Here is something you can do instead.
1. Create a new project
2. Add Notepad.exe to the project
3. Go to registry view and create a path where you want to store this file's location
4. Create a string entry in this key and set it's value to:

[!NOTEPAD.EXE]

5. Build and install

Now if you check the registry key it should have the path to where notepad.exe was installed (using SFN convention). The value of the registry key has to be the FileKey and NOT the filename and is case sensitive. In most cases (when there are no spaces in the name) the FileKey is the same as the FileName. The best way to figure out the FileKey would be to open the built msi in ORCA, go to the File Table and look at the first column of the row corresponding to the file you want.

geoffcox
12-04-2002, 02:54 PM
Originally posted by Chandima
I'm afraid Express 4.0 does not support this (it's called "AppPaths" in Developer). I've been pushing this for a while it keeps getting left out.

Chandima,

do keep pushing! I have recently had a look at Innosetup (free) and there you can use {reg:HKLM etc} to read a value from the registry and use it in the creation of a shortcut, eg

{reg:HKLM\Software\Javasoft\Java Runtime Environment\1.1,JavaHome}\bin\jrew.exe

this allows me to find where the user has installed the JRE and then create a shortcut.

Developer will cost a minor fortune I suppose?!

Cheers

Geoff

Here is something you can do instead.
1. Create a new project
2. Add Notepad.exe to the project
3. Go to registry view and create a path where you want to store this file's location
4. Create a string entry in this key and set it's value to:

[!NOTEPAD.EXE]

5. Build and install

Now if you check the registry key it should have the path to where notepad.exe was installed (using SFN convention). The value of the registry key has to be the FileKey and NOT the filename and is case sensitive. In most cases (when there are no spaces in the name) the FileKey is the same as the FileName. The best way to figure out the FileKey would be to open the built msi in ORCA, go to the File Table and look at the first column of the row corresponding to the file you want.

Chandima
12-04-2002, 03:53 PM
Actually submitted Work Order 1-BXV4Q as a feature request today to address this. For this particular instance, try the following:

Go to the Requirements view and create a new Software System Requirement (using wizard) that finds a "Registry entry, that contains a file path". Configure it's "How do you want to look for it?" panel as follows:

Registry Root: HKEY_LOCAL_MACHINE
Registry Key: Software\Javasoft\Java Runtime Environment\1.1
Registry Value: JavaHome

On the last panel give a message like "Test" and complete the wizard. Now change the state of the search check box to the empty box. This means it will perform the search but not stop the setup based on the results. Suppose the name given to this search is JAVAHOME. If so, at runtime, the property JAVAHOME will contain the value in the registry key you looked for. If the key is empty or missing this property will hold an empty value.

Now go to the Shortcut View and create a new "Shortcut to Predefined file". Create a root level folder called "TEST123". Set it's "Directory Identifier" property to TEST123. Set the FileName property to "jrew.exe" and close the dialog.

Now create a VBScript Custom Action with the following code:

Dim JavaHome
JavaHome = Session.Property("JAVAHOME")
Session.Property("TEST123") = JavaHome & "\bin"
MsgBox Session.Property("TEST123")

This (technically) should create a shortcut that points to jrew.exe.

geoffcox
12-05-2002, 09:08 AM
Chandima,

thanks for all your effort. I should have made clear I have not upgraded to v4 yet. I was hoping that the AppPath would be available ....

Cheers

Geoff

Chandima
12-06-2002, 12:20 PM
Not a problem. I am assuming we will eventually put App Paths in Express so then this should be useful :).

geoffcox
12-11-2002, 07:22 AM
Chandima,

in your VBScript doesn't this put up a message box? What I need is a desktop shortcut and also a Start/Program entry...

So,

1. I install the Java Runtime Environment package which includes jrew.exe as a Custom Action
2. I run the registry search to find where the user has put the JRE files, in particular the jrew.exe file
3. I then create desktop (and Program) shorcuts which will have a path such as d:\jrefiles\bin\jrew.exe
4. this path to jrew.exe must also have an argument such as "-classpath .;fred.jar;[INSTALLDIR]jane.jar ed.Word.Speech /url=file://[INSTALLDIR]text.htm"

Does this make my problem any clearer?!

Cheers

Geoff



[i]Originally posted by Chandima
Actually submitted Work Order 1-BXV4Q as a feature request today to address this. For this particular instance, try the following:

Go to the Requirements view and create a new Software System Requirement (using wizard) that finds a "Registry entry, that contains a file path". Configure it's "How do you want to look for it?" panel as follows:

Registry Root: HKEY_LOCAL_MACHINE
Registry Key: Software\Javasoft\Java Runtime Environment\1.1
Registry Value: JavaHome

On the last panel give a message like "Test" and complete the wizard. Now change the state of the search check box to the empty box. This means it will perform the search but not stop the setup based on the results. Suppose the name given to this search is JAVAHOME. If so, at runtime, the property JAVAHOME will contain the value in the registry key you looked for. If the key is empty or missing this property will hold an empty value.

Now go to the Shortcut View and create a new "Shortcut to Predefined file". Create a root level folder called "TEST123". Set it's "Directory Identifier" property to TEST123. Set the FileName property to "jrew.exe" and close the dialog.

Now create a VBScript Custom Action with the following code:

Dim JavaHome
JavaHome = Session.Property("JAVAHOME")
Session.Property("TEST123") = JavaHome & "\bin"
MsgBox Session.Property("TEST123")

This (technically) should create a shortcut that points to jrew.exe.

Chandima
12-11-2002, 12:53 PM
OK let's simplaify things a little. Is Jrew.exe a file you install or is it something that you assume is going to be on the end user's system?

Assuming this file is already on the users machine when you run your setup, you can use the "System Search Wizard" to either search the registry for a key that contains a path to this file, or actually search the target machine itself for this file. Each search will store information in a variable. The name of this variable is what appears in the Requirements view as the name of the search. So suppose your search is named JAVAHOME, and the search looks for the Jrew.exe on target machine and finds it, the JAVAHOME variable (or property) will contain the fully qualified path to this file.

If your setup is installing this file we can easily find out where the file is getting installed to. If you are running a custom action to install this file, then we might have a problem.

As for creating the shortcut, if the standard way fails we can always create it through a VBScript custom action.

geoffcox
12-11-2002, 02:53 PM
Originally posted by Chandima
OK let's simplaify things a little. Is Jrew.exe a file you install or is it something that you assume is going to be on the end user's system?

Chandima,

the jrew.exe is installed by my package as part of the Java Runtime Environment software. You will remember my separate thread re the "WinExec failed: return 87" problem whcih you solved by suggesting that I should use [SUPPORTDIR] etc.

So my hope would be that the JRE would be installed and then the registry search would find the path to the jrew.exe file.

Why should running a Custom Action be a problem? I guess it has to be that way as the JRE comes from Sun as a self extracting exe package...

You had given me a possible VBScript but as I said earlier I did not find that the TEST123 folder had been created even though the shortcut created had it in its path...

any ideas?

Cheers

Geoff

Assuming this file is already on the users machine when you run your setup, you can use the "System Search Wizard" to either search the registry for a key that contains a path to this file, or actually search the target machine itself for this file. Each search will store information in a variable. The name of this variable is what appears in the Requirements view as the name of the search. So suppose your search is named JAVAHOME, and the search looks for the Jrew.exe on target machine and finds it, the JAVAHOME variable (or property) will contain the fully qualified path to this file.

If your setup is installing this file we can easily find out where the file is getting installed to. If you are running a custom action to install this file, then we might have a problem.

As for creating the shortcut, if the standard way fails we can always create it through a VBScript custom action.

geoffcox
12-11-2002, 03:07 PM
Chandima,

in your VBScript doesn't this put up a message box? What I need is a desktop shortcut and also a Start/Program entry...

So,

1. I install the Java Runtime Environment package which includes jrew.exe as a Custom Action
2. I run the registry search to find where the user has put the JRE files, in particular the jrew.exe file
3. I then create desktop (and Program) shorcuts which will have a path such as d:\jrefiles\bin\jrew.exe
4. this path to jrew.exe must also have an argument such as "-classpath .;[INSTALLDIR]fred.jar;[INSTALLDIR]jane.jar ed.Word.Speech /url=file://[INSTALLDIR]text.htm"

Does this make my problem any clearer?!

Cheers

Geoff