Writing values from a text file to the registry
Posted: 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?
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?