MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: SUBST Command[Next]: Extract Binary at Install Time
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->File and Directory->Trailing Slash Removal

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].").


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 12 Jun 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: SUBST Command[Next]: Extract Binary at Install Time


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Wednesday June 25 2008 at 7:16pm
Visit MAKEMSI's Home PageThis external link was OK when tested at 21 Jun 2008

HTML page dated Mon, 29 Jan 2007 00:11:11 GMT
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 12 Jun 2008