\
Windows Installer FAQ (the basics)
Formatted Strings
$$WI_FMT PPWIZARD Transformation for Commands
$$WI_FMT PPWIZARD Transformation for Commands |
If you wanted to create a shortcut where either the "target" or "arguments"
contains "[" or "]" (left or right square brackets),
but not for intentional Windows Installer formatting)
then this ppwizard transformation
is probably the best way to handle it.
The following "Shortcut" command's fragment will fail:
<$Shortcut Arguments='//NoLogo "[INSTALLDIR]Something[SquareCharsBeforeAndAfterCanBeMisInterpreted].vbs"' ...>
This one using the transformation will not fail
(as it escapes any square brackets it finds):
#define VBSNAME Something[SquareCharsBeforeAndAfterCanBeMisInterpreted].vbs
<$Shortcut Arguments='//NoLogo "[INSTALLDIR]<$VBSNAME $$WI_FMT>"' ...>
The above allows you to automatically apply the transformation, for example
"VBSNAME" might be used a number of times and its value may vary but the value
will always be correctly formatted, if you don't mind manually doing it
(perhaps the VBS is not referred to anywhere else) then this is how I'd do it
for readability and reliability
(the codes are quite cryptic and would be easy to get wrong):
<$Shortcut Arguments='//NoLogo "[INSTALLDIR]Something<$LSB>SquareCharsBeforeAndAfterCanBeMisInterpreted<$RSB>.vbs"' ...>
The transformation's MAKEMSI definitions:
;----------------------------------------------------------------------------
;--- Define the "$$" transformation "$$WI_FMT" ------------------------------
;----------------------------------------------------------------------------
; SEE:
; 1. http://makemsi-manual.dennisbareis.com/formatted_strings.htm
; 2. http://dennisbareis.com/ppwizard/dd_qm.htm
;----------------------------------------------------------------------------
#define LSB [\[] ;;[
#define RSB [\]] ;;]
#DefineRexx "REXX_$$WI_FMT"
;--- Swap the problematic characters with pacemarkers -------------------
@@LSB_PM = "{@@LSB}"
@@RSB_PM = "{@@RSB}"
TheValue = ReplaceString(TheValue, '[', @@LSB_PM);
TheValue = ReplaceString(TheValue, ']', @@RSB_PM);
;--- Replace the place markers with the codes ---------------------------
TheValue = ReplaceString(TheValue, @@LSB_PM, '<$LSB>');
TheValue = ReplaceString(TheValue, @@RSB_PM, '<$RSB>');
#DefineRexx