Reading the Install Directory from Registry Keys

This forum has been archived and is no longer active.

The new forum is located at:

https://sourceforge.net/apps/phpbb/installjammer/

You may continue to view and search the topics in this forum, but no new posts can be created.

Reading the Install Directory from Registry Keys

Postby Afforess » Sat Nov 21, 2009 12:18 pm

If I wanted to set up my installer so the Install Directory pointed to a location specified by some registry keys, how would I go about doing this?
Afforess
 
Posts: 25
Joined: Thu Aug 20, 2009 9:21 pm

Re: Reading the Install Directory from Registry Keys

Postby damon » Mon Nov 23, 2009 2:35 pm

Getting a value from the registry is easy enough to do, but the current mechanism for doing it is busted and causes more problems than it solves. Given that, I would use an Execute Script action with this quick script:

Code: Select all
set key {HKEY_LOCAL_MACHINE\Software\Whatever\MyKey}
set val InstallDir
if {![catch {registry get $key $val} value]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value
}


This will attempt to fetch the key in $key and the value in $val, and if it finds it, it will set <%InstallDir%> to that value.
To file an issue, please visit:

http://tracker.installjammer.com/
damon
Site Admin
 
Posts: 4404
Joined: Sat Sep 15, 2007 2:46 pm

Re: Reading the Install Directory from Registry Keys

Postby Afforess » Wed Dec 16, 2009 12:33 pm

I tried this, but it doesn't seem to work. Could you tell me what's wrong with my script?

Code: Select all
set FIRAXIS_KEY {HKEY_LOCAL_MACHINE\Software\Firaxis Games}
set val {INSTALLDIR}

if {![catch {registry get $FIRAXIS_KEY\Sid Meier's Civilization 4 - Beyond the Sword $val} value]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value/Mods/Rise of Mankind
}

if {![catch {registry get $FIRAXIS_KEY\Sid Meier's Civilization 4 Complete $val} value]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value/Mods/Rise of Mankind
}

if {![catch {registry get $FIRAXIS_KEY\Sid Meier's Civilization 4 Gold $val} value]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value/Mods/Rise of Mankind
}
Afforess
 
Posts: 25
Joined: Thu Aug 20, 2009 9:21 pm

Re: Reading the Install Directory from Registry Keys

Postby pdunnigan » Wed Dec 16, 2009 1:52 pm

Are you seeing an error at all? What sort of behavior are you seeing?

Here's a guess: the spaces are fouling you up.

Change
if {![catch {registry get $FIRAXIS_KEY\Sid Meier's Civilization 4 - Beyond the Sword $val} value]} {
::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value/Mods/Rise of Mankind
}

to

if {![catch {registry get "$FIRAXIS_KEY\Sid Meier's Civilization 4 - Beyond the Sword $val"} value]} {
::InstallAPI::SetVirtualText -virtualtext InstallDir -value "$value/Mods/Rise of Mankind"
}

in all of your registry gets. You could also for testing purposes remove the catch statement to see what's really going on.
pdunnigan
 
Posts: 17
Joined: Wed Feb 18, 2009 11:22 am

Re: Reading the Install Directory from Registry Keys

Postby damon » Mon Dec 21, 2009 12:50 pm

pdunnigan is right. The spaces are fouling you up. If you want to be sure you've got it right, use variables instead. Like this:

Code: Select all
set key "$FIRAXIS_KEY\\Sid Meier's Civilization 4 - Beyond the Sword"
if {![catch {registry get $key $val} value]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value
}


Note that the whole variable value is in quotes, and you have to escape backslashes with another backslash. That should get you what you're looking for.
To file an issue, please visit:

http://tracker.installjammer.com/
damon
Site Admin
 
Posts: 4404
Joined: Sat Sep 15, 2007 2:46 pm

Re: Reading the Install Directory from Registry Keys

Postby JohnnyMcFly » Mon Nov 22, 2010 5:22 am

I am new to IJ, I have been using Inno for all our installs. It has served us well in the past, but IJ just seems that we will be able to go further.

I have been meaning to introduce myself, and will do that right after this post, but in the mean time, I have a question related to this thread.

We make VST audio Plugins that are shared between many recording software programs. The sort of "standard" location to install these plugins is identified under a registry key being..

HKLM\Software\VST\VSTPluginsPath

This registry key points to a shared path that most recording software uses to access plugins

set key "$FIRAXIS_KEY\\Sid Meier's Civilization 4 - Beyond the Sword"
if {![catch {registry get $key $val} value]} {
::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value
}

I am having a hard time trying to adapt the above script to read the
value stored at..
HKLM\Software\VST\VSTPluginsPath

Could someone please give me an example of this? Like what does $FIRAXIS_KEY refer to? is that the variable where the value is stored in? If so how does $key $val return that value? or are these setting the value to the registry key for where to look? I see no other reference to $FIRAXIS_KEY so I don't know what its doing...
Is 'set key' Storing the entire "$FIRAXIS_KEY\\Sid Meier's Civilization 4 - Beyond the Sword" as a variable in the $key? I figured one would need a '$' in front of Key to identify it as a variable when setting its contents, no?

So,
set key "HKEY_LOCAL_MACHINE\\Software\\VST\\VSTPluginsPath"
if {![catch {registry get $key $val} value]} {
::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value
}
Should work?

Thanks
Last edited by JohnnyMcFly on Mon Nov 22, 2010 7:33 am, edited 1 time in total.
JohnnyMcFly
 
Posts: 17
Joined: Mon Nov 22, 2010 4:55 am

Re: Reading the Install Directory from Registry Keys

Postby JohnnyMcFly » Mon Nov 22, 2010 7:28 am

Nevermind about my questions above, been developing for like 12 hours and missed half the postings above. Sorry
I guess it does not matter anyways, been trying to get this to work for like 5 hours and getting nowhere really fast.
I just can't get this to do anything...
I have added my script to an execute script action of the select destination pane, I have modified the script a gazillion times.
Here is what I ended up with

set key "{HKEY_LOCAL_MACHINE\\Software\\VST}"
set val "VSTPluginsPath"
if {![catch {registry get $key $val} value]} {
::InstallAPI::SetVirtualText -virtualtext InstallDir -value $value
}

I wish the <%RegValue%> worked as well, that would have solved my issue really quickly

Thanks...
This prog shows a lot of promise, I'd like to get back to it sooner or later but like everyone else I have time constraints so for now I guess I just have to try and fix my INNO script. Inno is good, I am not trying to dis it, but I don't think it is robust enough for our future installs, obviously we're already running into trouble with it. I think IJ will be, but we just need some of the simple stuff like reading a registry value and using it to fill in text entry boxes. In terms of interface and what not, it really does look great, you have done an excellent job...
Thank you for your work thus far and I look forward to seeing how IJ progresses
JohnnyMcFly
 
Posts: 17
Joined: Mon Nov 22, 2010 4:55 am

Re: Reading the Install Directory from Registry Keys

Postby damon » Mon Nov 22, 2010 11:22 am

Sorry you didn't get with me sooner. I'm always available to help out, especially if you're on a time crunch. In the future, don't be afraid to drop me an email if you're in a crunch. I'm a developer too, and we've all been down to the wire. I like to help out where I can.

What you probably want is this:

Code: Select all
set key {HKEY_LOCAL_MACHINE\Software\VST}
set val "VSTPluginsPath"
if {![catch {registry get $key $val} path]} {
    ::InstallAPI::SetVirtualText -virtualtext InstallDir $path
}


This will grab the registry value and stuff it in <%InstallDir%>. Which means it will overwrite the default destination directory for your installer so that the whole thing will install in that plugins directory.

The problem is that Tcl's parsing semantics can be a little tricky if you don't know them, even though there are really only 13 syntax rules to the entire language. In this particular case, we're using { } to surround our variable value because anything placed within curly braces like that does not get substituted. Meaning that our backslashes will remain instead of being interpreted. This just saves us from having to escape them. The following two statements are synonymous:

Code: Select all
set foo "HKEY_LOCAL_MACHINE\\Software\\VST"
set foo {HKEY_LOCAL_MACHINE\Software\VST}


When we use quotes, we have to escape the backslashes. When we curly braces, we don't. Nothing is substituted within the curly braces. Just one of those things you learn after doing the language for so long. It trips a lot of people up the first time or when reading scripts from the forum. I tend to use things interchangeably depending on my mood, and I'm sure that doesn't help people reading the forums and trying to decipher the meaning of my scripts. 0-]

Let me know if there's anything else I can help with when you get back to this.
To file an issue, please visit:

http://tracker.installjammer.com/
damon
Site Admin
 
Posts: 4404
Joined: Sat Sep 15, 2007 2:46 pm

Re: Reading the Install Directory from Registry Keys

Postby JohnnyMcFly » Mon Nov 22, 2010 11:49 am

Damon thanks I'll try that, and I'll let you know how I make out..
Once again thanks
JohnnyMcFly
 
Posts: 17
Joined: Mon Nov 22, 2010 4:55 am

Re: Reading the Install Directory from Registry Keys

Postby JohnnyMcFly » Mon Nov 22, 2010 12:04 pm

I got an error in the script, I have looked and not really sure what to do as this language is not something I am familiar with.
Its says key-value pairs, so would that be something like Set <%VIRTUALTEXT%> = "WHATEVER" I don't know? Just a guess

You know what would be great is to be able to go <%RegistryKey%> in the destination part of the pane...Done, simple..:)
Its very interesting for me to be on the other side of the fence asking for additions to another developer..:)

Here's the error...

Error in action ExecuteScript

invalid number of arguments passed to ::InstallAPI::SetVirtualText: all arguments must be key-value pairs
while executing
"::InstallJammer::actions::$component $this"
Error in action ExecuteScript

invalid number of arguments passed to ::InstallAPI::SetVirtualText: all arguments must be key-value pairs
while executing
"::InstallJammer::actions::$component $this"
while executing
"$obj execute"
(procedure "::InstallJammer::ExecuteActions" line 69)
invoked from within
"::InstallJammer::ExecuteActions $id -when $when"
(procedure "::InstallJammer::RaiseEventHandler" line 93)
invoked from within
"::InstallJammer::RaiseEventHandler .wizard"
(command bound to event)
JohnnyMcFly
 
Posts: 17
Joined: Mon Nov 22, 2010 4:55 am

Next

Return to Help

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron