Does Registry Appending work (documentation says so...)?

209 views
Skip to first unread message

dbareis [Windows Installer MVP]

unread,
Dec 3, 2007, 8:04:08 PM12/3/07
to
Hi,

This is a registry row that causes registry REPLACEMENT (as the string
list starts with "[~]" it should have appended):

<$Row
Registry="RegKey002"
Root="2"
Key="SYSTEM\CurrentControlSet\Control\Session
Manager"
Name="BootExecute"
Value="#%[~][INSTALLDIR]Some.exe"
Component_="PinPadStartupScript"
>

Has anyone got it to work or is the latest (and older) SDK doco wrong?

Thanks for any help,
Dennis

Adrian Accinelli

unread,
Dec 4, 2007, 2:18:32 PM12/4/07
to

"dbareis [Windows Installer MVP]" <dba...@gmail.com> wrote in message
news:09182065-e9c4-4e90...@d21g2000prf.googlegroups.com...

I've seen prepend/append in REG_MULTI_SZ working for sure.

If [~] is included in the value at all it changes the intent for the
registry item to be REG_MULTI_SZ. The value you show starts as #% which
indicates REG_EXPAND_SZ. I think the whole prepend/append applies only to
REG_MULTI_SZ or to the environment table (which although is in registry I'm
sure has specific code in Windows Installer engine to handle due to old 9X
support).

So I am guessing based on your results that if Windows Installer finds that
the Value starts with # (but not ##) then it ignores [~] behaviour for
prepend/append.

Which means changing


Value="#%[~][INSTALLDIR]Some.exe"

to
Value="[~][INSTALLDIR]Some.exe"
should work.

Sincerely,
Adrian Accinelli


Christopher Painter

unread,
Dec 4, 2007, 4:01:14 PM12/4/07
to
Registry types REG_EXPAND_SZ and REG_MULTI_SZ are mutually
exculsive. Regedit ( and InstallShield for that matter ) makes you
choose between String, Binary, DWORD, Multi and Exapandable. In
InstallShield it's a simple right-click | New Multi-String Value
followed by a dialog that gives you a list of values and a setting of
prepend ( [~]data), append ( data[~] ) and replace ( [~]data[~] )

Besides, in your example, [INSTALLDIR] is an MSI Public Property that
will be formatted before writing to the registry. Expandable is for
registry value data that contains environment variables and will be
expanded when the value is later read.

Adrian Accinelli

unread,
Dec 4, 2007, 6:50:45 PM12/4/07
to

"Christopher Painter" <chr...@yahoo.com> wrote in message
news:4b1df16d-56f2-48f4...@f3g2000hsg.googlegroups.com...

I hope I wasn't conveying that you could do the impossible. I think Dennis
was under the impression that the Windows Installer would allow you to
prepend/append a string into an existing REG_EXPAND_SZ value. E.g. Existing
value is "Blah". So by creating registry table entry like "#%[~]Something"
he thought the result would be "BlahSomething" -- all still in
REG_EXPAND_SZ. Maybe I'm wrong but that's my interpretation of the posting.

Also I like the idea of "Proof by UI" but I do not seriously think that you
can't rely on UI of any app to tell you a real answer. Case in point:
Regedit on XP doesn't provide "new QWORD value" menu item but Vista does.
But you can create them with direct API since 2000 (or I suppose by using
"new Binary value" but that's not my point). Sure in this case both you
and the UI you reference are correct but just I don't think it's acceptable
for a definitive answer. Still... something about "Proof by UI" appeals to
me :)

Sincerely,
Adrian Accinelli


Christopher Painter

unread,
Dec 4, 2007, 9:09:22 PM12/4/07
to
The PSDK is notoriously cryptic and it takes several readings
( sometimes over many years ) to pick up understanding form subtle
statements. Like this one:

(From Registry Table Topic )

"#% The value is interpreted and stored as an expandable string
(REG_EXPAND_SZ)."

but then it goes on to say:

"If the value contains the sequence tilde [~], then the value is
interpreted as a Null-delimited list of strings (REG_MULTI_SZ)."


Based on my understanding of the registry and experience with MSI,
the latter takes precedence over the former. Regardless it's a moot
point because [INSTALLDIR] isn't expandable anyways, it's formattable.

Christopher Painter

unread,
Dec 4, 2007, 9:29:11 PM12/4/07
to
Maybe the following will help. Note REG_EXPAND_SZ is null
terminated and a REG_MULTI_SZ is null delimited and that the registry
table says [~]'s are stored and interpreted as null's that it's
clearly not possible to try to define an expandable value that
contains multiple lines.


http://msdn2.microsoft.com/en-us/library/ms724884.aspx

REG_EXPAND_SZ : A null-terminated string that contains unexpanded
references to environment variables (for example, "%PATH%"). It will
be a Unicode or ANSI string depending on whether you use the Unicode
or ANSI functions. To expand the environment variable references, use
the ExpandEnvironmentStrings function.

REG_MULTI_SZ : A sequence of null-terminated strings, terminated by an
empty string (\0).
The following is an example:

String1\0String2\0String3\0LastString\0\0

The first \0 terminates the first string, the second to the last \0
terminates the last string, and the final \0 terminates the sequence.
Note that the final terminator must be factored into the length of the
string.

Adrian Accinelli

unread,
Dec 4, 2007, 10:30:24 PM12/4/07
to

"Christopher Painter" <chr...@yahoo.com> wrote in message
news:dd3114ad-2443-4dde...@e4g2000hsg.googlegroups.com...

> The PSDK is notoriously cryptic and it takes several readings
> ( sometimes over many years ) to pick up understanding form subtle
> statements. Like this one:
>
> (From Registry Table Topic )
>
> "#% The value is interpreted and stored as an expandable string
> (REG_EXPAND_SZ)."
>
> but then it goes on to say:
>
> "If the value contains the sequence tilde [~], then the value is
> interpreted as a Null-delimited list of strings (REG_MULTI_SZ)."
>

Right -- that's the exact wording I was looking at before I posted. I came
to the same conclusion as you but since I never tried it directly (come on
who needs that really?) so I gave the Dennis benefit of the doubt and posted
as if docs could be wrong but likely were not and maybe he just had a
typo...

>
> Based on my understanding of the registry and experience with MSI,
> the latter takes precedence over the former. Regardless it's a moot
> point because [INSTALLDIR] isn't expandable anyways, it's formattable.

Agreed... hehehe this is just for fun now --> Formatted still allows [\%] so
the INSTALLDIR could be craftily constructed to provide expanded status
(e.g. "[\%]ProgramFiles[\%]Whatever"). Of course it wouldn't be good for
use as a Directory table value in that form but fine for registry
REG_EXPAND_SZ purposes.

No more posts from me on this topic I promise!

Sincerely,
Adrian Accinelli


Christopher Painter

unread,
Dec 4, 2007, 10:42:11 PM12/4/07
to
On Dec 4, 9:30 pm, "Adrian Accinelli"

<hclnospamali...@newsgroup.nospam> wrote:
> No more posts from me on this topic I promise!

Hehehehe

I agree. Time to stop theorizing and get back to making money writing
installs for customers. :-)

Dennis Bareis

unread,
Dec 5, 2007, 1:55:55 AM12/5/07
to


Thanks guys, yes I was getting confused and the documenation certainly doesn't help,
in my case I did want REG_MULTI_SZ and taking out the "#%" did the trick.

But (from other posts), just because a registry value is of type REG_EXPAND_SZ doesn't
mean it need contain a value which REQUIRES expanding.

Bye,
Dennis
Dennis Bareis [Microsoft MVP] (dba...@KillSpam.gmail.com)
http://dennisbareis.com/
Freeware Windows Installer creation tool (+ "ORCA automation"):
http://makemsi.dennisbareis.com/

Reply all
Reply to author
Forward
0 new messages