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]: ProvideComponent[Next]: Uninstalling PER-USER Resources
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Windows Installer FAQ (the basics)->Installation Types (per-user or per-machine)->Per-Machine Installations with some Per-User Resources->Startup Folder Shortcut (to provide advertising)

Startup Folder Shortcut (to provide advertising)

Where there is no other advertising mechanism being setup by your msi a common approach is to use a "allusers" (per-machine) advertised shortcut which will invoke the repair.

The invoked task can be anything that is "silent" and need not actually do anything as you are mainly interested in the advertising aspect.

Be aware that the files are not uninstalled along with the package except for the user performing the uninstall.

Example

Note that as files are copied at user logon the original source msi will need to be available after install.

If this is not desired then you would need to first install the per-user resources to a per-machine location and the script would now have to copy the files to the per-user location from the installed copy.

;--- Include MAKEMSI support (with my customisations and MSI branding) ------
#include "ME.MMH"


;--- Want single directory of files to go to the user's  "TEMP" directory ---
<$Component "PerUserFiles" Create="Y" Directory_="TempFolder" CU="Y">   ;;Components need "per user" keypath!
    <$Files "TryMe.*">
    <$MsiValFilter "Component 'PerUserFiles' has both per-user and per-machine data with an HKCU Registry KeyPath">
<$/Component>


;--- Load whole tree of files (let components be generated with "current user" keypath ---
<$MacroCfg "FILE_GENERATED_COMPONENT_USE_FILE_AS_KEYPATH" VALUE="N" PreExists="Y">    ;;We are specifying CU registry keypath, prevent "FILES" command overwriting this.
    #define HANDY_SMALL_TREE C:\Program Files\MakeMsi\Samples\TryMe\Create MSI Installers\Localisation to Dutch
    <$Files "<$HANDY_SMALL_TREE>\*" DestDir="TempFolder" Options4Component=^CU='Y'^ SubDir="TREE">
    <$MsiValFilter RE="Y" "Component '<$FILE_GENERATED_COMPONENT_PREFIX>.*' has both per-user and per-machine data with an HKCU Registry KeyPath">
<$/MacroCfg>


;--- OK now lets create an empty VBSCRIPT (needs something that "does nothing"!) ---
#define  DoesNothing.VBS_BASENAME  DoesNothing.VBS
#define  DoesNothing.VBS           <$MAKEMSI_OTHER_DIR>\<$DoesNothing.VBS_BASENAME>
#define  DoesNothingComment        This does nothing!  The advertised shortcut installs the files to the users 'temp' directory
#define  DoesNothingScDesc         Configures <$ProdInfo.ProductName> v<$ProductVersion>
<$FileMake "<$DoesNothing.VBS>">
    '--- <$DoesNothingComment> ---
    <?SyntaxCheck>                 ;;Required for VBS, inserts syntax code validation for VBSCRIPT
<$/FileMake>


;--- Now create the startup folder shortcut (advertising the above feature) ---
<$DirectoryTree Key="INSTALLDIR" Dir="[ProgramFilesFolder]\<$ProdInfo.ProductName>" CHANGE="\" PrimaryFolder="Y">
<$Component "StartupRepair" Create="Y" Directory_="INSTALLDIR">
   <$File Source="<$DoesNothing.VBS>" Comment='<$DoesNothingComment>' KeyPath="Y">
   #(
       <$Shortcut
                   Dir="StartupFolder"
               Feature="."                                        ;;Note that WSCRIPT.EXE is associated to .vbs"
                 Title="<$DoesNothingScDesc>"
           Description="<$DoesNothingScDesc>"                     ;;Best to reasure user who may be wondering what this is... Unfortunately can't be too long...
               WorkDir="INSTALLDIR"
                  Icon="@Tryme.ico"
       >
   #)
<$/Component>

In the above we are installing into the special folder property "TempFolder" which resolves to a per-user location for both per-machine and per-user installs.

Note that if as in the above you install files via components with a "current user" registry keypath, when the component gets installed the value of "TempFolder" will be resolved to be correct for that user. If the keypath is a file/directory based one then Windows Installer "repairs" the originally installed component so that files don't get installed for each user (they get repaired if required for the user who did the original install)!


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: ProvideComponent[Next]: Uninstalling PER-USER Resources


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.