Writing values from a text file to the registry

Got a problem you cannot solve? Try here.
tomriley
Posts: 3
Joined: Tue Sep 19, 2006 8:21 am

Writing values from a text file to the registry

Postby tomriley » Mon Sep 25, 2006 9:00 am

I have added a text file to the project as a support file, and intend to use it to configure the set of registry values that will be written on install (by storing values in this file as a comma separated list Type, Key, Name, Value.

I am currently using the following script to do this:

Set Variable REGISTRY_ENTRY to
Set Variable REGISTRY_ENTRY_EOF to
Set Variable REGISTRY_TYPE to
Set Variable REGISTRY_VALUE to
Set Variable REGISTRY_KEY to
Set Variable REGISTRY_DATA to
label: READ_REG_FILE
if Variable Remove not Equals TRUE
Read from Text File $SUPPORTDIR$\\RegistrySettings.txt into Variable REGISTRY_ENTRY (get EOF into REGISTRY_ENTRY_EOF)
Parse String $REGISTRY_ENTRY$ into Variables REGISTRY_TYPE and REGISTRY_ENTRY (Split at first occurrence of pattern)
Parse String $REGISTRY_ENTRY$ into Variables REGISTRY_KEY and REGISTRY_VALUE (Split at first occurrence of pattern)
Parse String $REGISTRY_VALUE$ into Variables REGISTRY_VALUE and REGISTRY_DATA (Split at first occurrence of pattern)
if Variable REGISTRY_TYPE Equals String
Write Registry Key HKCU\\$REGISTRY_KEY$\\$REGISTRY_VALUE$, $REGISTRY_DATA$
end
if Variable REGISTRY_TYPE Equals Int
Write Registry Key HKCU\\$REGISTRY_KEY$\\$REGISTRY_VALUE$, $REGISTRY_DATA$
end
if Variable REGISTRY_TYPE Equals Binary
Write Registry Key HKCU\\$REGISTRY_KEY$\\$REGISTRY_VALUE$, $REGISTRY_DATA$
end
if Variable REGISTRY_ENTRY_EOF Equals FALSE
GoTo Label: READ_REG_FILE
end
end



This looks to me like it should work, but when I run it, only the last line of the file is actually written to the registry. Does anyone know why this is?

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Mon Sep 25, 2006 12:14 pm

This is because you cannot loop Windows Installer commands in the setup script - please read this whitepaper for information:

http://www.installaware.com/msicode_scr ... nology.pdf
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

tomriley
Posts: 3
Joined: Tue Sep 19, 2006 8:21 am

Postby tomriley » Tue Sep 26, 2006 9:05 am

Thanks for that. Does anyone know a method of reading the registry values from a configuration file so that I don't have to import entries from my registry every time I make a change?

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Tue Sep 26, 2006 12:54 pm

You can just merge a .reg file silently at install time.
Michael Nesmith

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/

tomriley
Posts: 3
Joined: Tue Sep 19, 2006 8:21 am

Postby tomriley » Thu Oct 12, 2006 8:49 am

Thanks again. Any chance of a few pointers on how to do this? I've looked in the help and not managed to find anything.

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Thu Oct 12, 2006 4:44 pm

Use Run Program with regedit to silently merge the .reg file with your registry. The silent parameter might be /s or /y - a quick Google search should reveal this information for you.
Michael Nesmith

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 218 guests