|
![]() |
| Trailing Slash Removal |
The following custom action shows how you could get the value of the "INSTALLDIR" directory and create a version which does not have the trailing backslash.
A similar process could be used for determining 8.3 names etc.
;--- VBSCRIPT to read "INSTALLDIR" and create to "INSTALLDIR_NTS" -----------
<$VbsCa Binary="RemoveSlashFromINSTALLDIR.vbs">
<$VbsCaEntry "RemoveTrailingSlash">
;--- Define any VB variables ----------------------------------------
dim InputValue, OutputValue
;--- Get the properties current value -------------------------------
InputValue = session.property("INSTALLDIR")
CaDebug 0, "INSTALLDIR = """ & InputValue & """"
;--- Manipulate the value -------------------------------------------
if right(InputValue, 1) <> "\" then
OutputValue = InputValue ;;Already "slashless"
else
OutputValue = left(InputValue, len(InputValue)-1) ;;Remove last character (slash)
end if
;--- Return the value -----------------------------------------------
CaDebug 0, "INSTALLDIR_NTS = """ & OutputValue & """"
session.property("INSTALLDIR_NTS") = OutputValue
<$/VbsCaEntry>
<$/VbsCa>
;--- Call the above script during install and uninstall ---------------------
<$VbsCaSetup Binary="RemoveSlashFromINSTALLDIR.vbs" Entry="RemoveTrailingSlash" Seq="InstallValidate-" CONDITION=^<$CONDITION_INSTALL_ONLY>^ Type="IMMEDIATE">
;--- Test the value we created above ----------------------------------------
<$Component "TestValues" Create="Y" Directory_="INSTALLDIR">
<$Registry HKEY="LOCAL_MACHINE" KEY="software\testmsi\WithSlash" VALUE="[INSTALLDIR]" MsiFormatted="VALUE">
<$Registry HKEY="LOCAL_MACHINE" KEY="software\testmsi\NoSlash" VALUE="[INSTALLDIR_NTS]" MsiFormatted="VALUE">
<$/Component>
While this is a generic example which just uses slash removal for the example if this is actually all you wish to do then you may have a workaround which doesn't need a custom action and that is to terminate the value with a "." (for example "[INSTALLDIR].").
![]() | ![]() |