PDA

View Full Version : Creating Session Variables


gott
09-07-2007, 12:15 PM
I am attempting to install certain files to a folder that I am trying to determine its location from the registry. On the On Pre-Install tab for Actions, I defined a variable that uses "Registry.GetValue" to find the path of the program. When I attempt to build, I receive a message that the file cannot be created in the directory. If you define a variable like I did using the On Pre-Install tab under Actions, how do you get the installer to recognize this variable? Are they the same as Session Variables?

jassing
09-07-2007, 05:51 PM
I am attempting to install certain files to a folder that I am trying to determine its location from the registry. On the On Pre-Install tab for Actions, I defined a variable that uses "Registry.GetValue" to find the path of the program. When I attempt to build, I receive a message that the file cannot be created in the directory. If you define a variable like I did using the On Pre-Install tab under Actions, how do you get the installer to recognize this variable? Are they the same as Session Variables?


What is the exact error you get on build?
what is the exact code you're using?
define a variable "like I did" -- how did you define it?
"lua" variables are not the same as session variables, if that's what you're asking...

gott
09-10-2007, 07:22 AM
Here is the code:

HomeDir=Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Company Name\\Program", "Home", false);


This is defined in the Pre-Install Action. There was no error code given when I received an error stating that the path could not be created. When I build the program and attempt to copy the files to the directory, the program states that it cannot since it cannot create the %HomeDir%\Program folder.

gott
09-10-2007, 09:12 AM
I have made some progress with this as well. My current code appears as the following:


SessionVar.Set("ProgramHome", Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Company Name\\Program", "Home", false));


It does appear to retrieve the correct home for the program folder from the registry. However, whenever I build an attempt to run the installer, it does seem to resolve the variable, but I receive the following error:

"Could not create %C:\Program%\"

It appears that the percentage signs are causing this. With my current code, how do I eliminate these?

jassing
09-10-2007, 09:46 AM
It appears that the percentage signs are causing this. With my current code, how do I eliminate these?

Glad you discovered the difference between a lua variable and a session variable...

Now, to your question -- the line which you keep quoting, would not cause an error at build time -- moreover -- I think when you say 'build' you mean install ??

In order to find the offending line, you'll need to identify what is trying to make that call -- I suspect you have other places where you've confused a lua and session variable.

gott
09-10-2007, 10:01 AM
I'm not certain if I understand. There doesn't appear to be any other line, just that the percentage signs are a part of the returned value for the variable. I don't know why these are stored in the %HomeDir% variable in the first place. Again, it is finding the correct path in the registry, just not concatenating the percentage signs from the resultant path.

gott
09-10-2007, 01:46 PM
Using the Registry.GetValue action, I am able to successfully read the registry and then return a dialog box that contains the correct value:


HomeDir=Registry.GetValue(HKEY_LOCAL_MACHINE, "Software\\Company Name\\Program", "Home", false);
Dialog.Message("Registry Data", "The value read from the Registry is "..HomeDir..".");


Whenever I set a SessionVar.Set action, I experience the problem where the installer cannot resolve the path, adding % signs to the beginning and the end of the path. The code for the SessionVar.Set line is the following:


SessionVar.Set("ProgramHome", "HomeDir");


I cannot figure out why this is not resolving. Is there another way to determine a path based upon a registry setting, and then store that path into a session variable?

csd214
09-11-2007, 09:04 AM
HomeDir is a (LUA) variable. “HomeDir” is a text string. I suggest following the correct syntax:

SessionVar.Set("%ProgramHome%", HomeDir);

Then use the session variable %ProgramHome% in the proper way and everything is fine. ;)

gott
09-11-2007, 11:07 AM
That worked. Thanks for the reply! Also, I was only using "HomeDir" as an example in this case. The actual variable is something unique.