Using variables in the Write Registry command?

Got a problem you cannot solve? Try here.
Frank
Posts: 59
Joined: Tue Oct 27, 2009 9:16 am
Location: Netherland

Using variables in the Write Registry command?

Postby Frank » Wed Jan 06, 2010 5:31 am

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
?

neillans
Posts: 536
Joined: Sat Nov 04, 2006 6:21 am
Location: Scottish Borders, UK
Contact:

Postby neillans » Wed Jan 06, 2010 3:56 pm

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.
Andy Neillans

Frank
Posts: 59
Joined: Tue Oct 27, 2009 9:16 am
Location: Netherland

Postby Frank » Thu Jan 07, 2010 7:17 am

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.

alimohti
Posts: 8
Joined: Mon Apr 18, 2011 6:33 am

Re: Using variables in the Write Registry command?

Postby alimohti » Thu May 19, 2011 5:25 am

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

alimohti
Posts: 8
Joined: Mon Apr 18, 2011 6:33 am

Re: Using variables in the Write Registry command?

Postby alimohti » Thu May 19, 2011 5:43 am

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

giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Using variables in the Write Registry command?

Postby giaviv » Thu May 19, 2011 7:19 am

Dear alimohti,

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

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Using variables in the Write Registry command?

Postby giaviv » Thu May 19, 2011 7:20 am

Dear alimohti,

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

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 66 guests