Page 1 of 1

Using variables in the Write Registry command?

Posted: Wed Jan 06, 2010 5:31 am
by Frank
Our product requires the installer to set some values in the registry concerning the Internet Settings. Among these values we'd like to add a servername to the trusted domains.

This server name isn't fixed, so currently we're building a installer per servername. This requires me to change all references to this servername in the script. If I miss one then the installer is not usable (I do feel I need to point out that this wasn't setup by yours truly :), I'm supposed to maintain it though :x )

I'd like two things:
1. How do I pass (dynamically) the servername to the MSI (use GPO command line variables perhaps?)
2. How do I dynamically write registry keys. The key needs to have a variable that holds the servername. Can I do

Code: Select all

Write Registry Key HDKU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Setting\\$SERVERNAME$\\2201, 0
?

Posted: Wed Jan 06, 2010 3:56 pm
by neillans
Hi Frank,

1. Is the server name the same as the machine name you are using? If so, you can use the Get Environment Variable option to get the name. If not, please have a look at the help file for command line parameters with regards to reading it from the command line input. You will need to have a look at the GPO "wrapper" details too if you are using GPO to build an MSI.

2. Should work :) Worst case, you will need to the full key into a variable and pass just that variable to the Write Registry function.

Posted: Thu Jan 07, 2010 7:17 am
by Frank
Ah, if life could only be that simple. :roll:

No, the name I'm after is the name of the webserver our application is talking to. We're trying to install our web client without user interaction. Our users don't know nor care about such trivial things. :wink:
Then there are the administrators who don't feel like naming their webserver to our specifications. :D
The thing I'm trying to do is minimized the changes in the script. If I can do that by changing MSI command line parameters, then I'm already happy. Right now I'm changing ten odd lines to get a 'new' server name. Big changes come in small steps...

I did find out that variables in Write Registry are no issue. Thank for your answers.

Re: Using variables in the Write Registry command?

Posted: Thu May 19, 2011 5:25 am
by alimohti
Hi neillans
Am reading a registry key and store it in a new variable to be written again to the registry, but the Write Registry seems not accepting the variables in the Value Field, below is my MSI code

Code: Select all

Set Variable FRAMEWORKINSTALLROOT to 
Set Variable EVENTLOGMESSAGE to EventLogMessages.dll
Read Registry Key HKLM\SOFTWARE\Microsoft\.NETFramework\InstallRoot into FRAMEWORKINSTALLROOT
Set Variable FRAMEWORKINSTALLROOTEVENT to $FRAMEWORKINSTALLROOT$$EVENTLOGMESSAGE$
Write Registry Key HKLM\SYSTEM\CurrentControlSet\services\eventlog\Application\Our Application\EventMessageFile, $FRAMEWORKINSTALLROOTEVENT$ (permanent)
Apply Install
the expected result for me is to write the value "C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll" to the EventMessageFile key
but the result i get is writting $FRAMEWORKINSTALLROOTEVENT$ not its value

Re: Using variables in the Write Registry command?

Posted: Thu May 19, 2011 5:43 am
by alimohti
I found the problem.
If you write a value to the registry using variables and the value type is "String" and/or "permanent" it will not write the key at all or write it with variable name not the variable value, but if you write the value of type "Expand String" WITHOUT "permanent" it will work fine

i don't know if this is a bug or my bad

Re: Using variables in the Write Registry command?

Posted: Thu May 19, 2011 7:19 am
by giaviv
Dear alimohti,

I don't think that this is a bug - thanks for letting us know anyway!

Re: Using variables in the Write Registry command?

Posted: Thu May 19, 2011 7:20 am
by giaviv
Dear alimohti,

I don't think that this is a bug - thanks for letting us know anyway!