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]: TryMeExcelAddIn.MM[Next]: TryMeShortcuts.MM
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->MAKEMSI Installs...->Samples Installed by MAKEMSI->Samples - Build New MSI/MSM->TryMeExtnAction.MM

TryMeExtnAction.MM

This is one of the MAKEMSI samples which build a new MSI/MSM. This MSI makes use of these "TryMe.MM" files:

  1. TryMe.ver
  2. TryMe.rtf
;----------------------------------------------------------------------------
;    MODULE NAME:   TryMeExtnAction.MM
;
;        $Author:   USER "Dennis"  $
;      $Revision:   1.0  $
;          $Date:   13 Apr 2015 17:34:50  $
;       $Logfile:   C:/DBAREIS/Projects.PVCS/Win32/MakeMsi/TryMeExtnAction.MM.pvcs  $
;
; DESCRIPTION
; ~~~~~~~~~~~
; This installs an Explorer "Right click->New->Command Prompt" command which
; you can use to open a command prompt at the current directory and unlike
; most similar tools it also handles UNC paths (\\server\...).
;
; It is of course mainly an example on how to install any "new" commands.
;
; The new icon may take a while or need multiple "New" menu invokations
; for the item to appear (not sure what triggers a refresh).
;----------------------------------------------------------------------------


;----------------------------------------------------------------------------
;--- Include MAKEMSI support (with my customisations and MSI branding) ------
;----------------------------------------------------------------------------
#define EXTN_DEFAULT_PROGID_PREFIX       ;;I don't want a prefix so its easier to find in regedit (just need to type ".aa" or "aa")
#define VER_FILENAME.VER  TryMe.Ver      ;;I only want one VER file for all samples! (this line not actually required in "tryme.mm")
#include "ME.MMH"


;----------------------------------------------------------------------------
;--- Define default location where file should install ---------------------
;----------------------------------------------------------------------------
<$DirectoryTree Key="INSTALLDIR" Dir="c:\program files\TryMe (makemsi sample)\<$MAKEMSI_MM_BASENAME>" CHANGE="\" PrimaryFolder="Y">


;----------------------------------------------------------------------------
;--- Build the code that will handle the right click new open option --------
;----------------------------------------------------------------------------
#define NewCmdPrompt.cmd_SHORT_NAME  NewCmdPrompt(TryMe).cmd
#define NewCmdPrompt.cmd             <$MAKEMSI_OTHER_DIR>\<$NewCmdPrompt.cmd_SHORT_NAME>
<$FileMake "<$NewCmdPrompt.cmd>">
    ::----------------------------------------------------------------------------------
    ::--- Get the name of the path (Windows doesn't handle UNC so needs some "magic) ---
    ::----------------------------------------------------------------------------------
    @echo off
    cls
    ::setlocal  ;;Can't use setlocal or it breaks the UNC "magic"...
    set FullNameOfNewFile=%~1
    for %%X in ("%FullNameOfNewFile%") do set JustFolder=%%~dpX

    <?NewLine><?NewLine>
    ::------------------------------------------------------------------------
    ::--- Display info -------------------------------------------------------
    ::------------------------------------------------------------------------
    color 02
    echo <$ProdInfo.ProductName> version <$ProductVersion> says hi :-)
    echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    echo Built         : <?CompileTime>
    echo Asked to build: %FullNameOfNewFile%
    echo Wanted Folder : %JustFolder%
    echo.
    echo.
    title TRYME: %JustFolder%

    <?NewLine><?NewLine>
    ::------------------------------------------------------------------------
    ::--- Change to the directory (swap drives if required) ------------------
    ::------------------------------------------------------------------------
    cd /d "%JustFolder%"
    if not errorlevel 1 goto ChangedOkSoNotUncPath
       pushd "%JustFolder%"
       echo.
       echo =======================================================================
       echo ===               TRYME UNC PATH HANDLER REQUIRED                   ===
       echo =======================================================================
       echo === You should type "exit" to quit and not simply close this window ===
       echo =======================================================================
       echo.
    :ChangedOkSoNotUncPath
    echo.
<$/FileMake>


;----------------------------------------------------------------------------
;--- Install the icon and the code ------------------------------------------
;----------------------------------------------------------------------------
<$Component "NewCmdPrompt" Create="Y" Directory_="INSTALLDIR">
    ;--- The script ---------------------------------------------------------
    <$File Source="<$NewCmdPrompt.cmd>" KeyPath="Y" Comment=^script to open a command prompt, invoked via "New" Shell menu^>

    ;--- The icon file (working around Windows Icon caching issues) ---------
    #evaluate ^RandomishIconBit^  ^'<$ProductVersion> - ' || time('s')^
    #define CMDPROMPT.ICO  <$ProdInfo.ProductName>-CmdPrompt (<$RandomishIconBit>).ico  ;;We will rename the icon to this
    <$File Source="TryMe.ico" Destination="<$CMDPROMPT.ICO>" Comment="Icon for New->Command Prompt">
<$/Component>


;----------------------------------------------------------------------------
;--- Set up the association required to launch the new command prompt -------
;----------------------------------------------------------------------------
<$Component "NewCmdPromptRegistry" Create="Y" Directory_="INSTALLDIR" CU="?">
    ;--- I prefix it with "aaaa" just to make it easier to find in regedit ---
    #define+ NEW_CMD_PROMPT_KEY   aaaa-New-TryMeCmdPrompt           ;;If this (ProgId) is "too long" in windows 7 then the  icon will not appear (bug #654,345,654 in Windows)

    ;--- Define the "ShellNew" entries required -----------------------------
    <$Extn ".<$NEW_CMD_PROMPT_KEY>" HKEY="HKMU" Description="Command Prompt (TryMe)" Icon=^[INSTALLDIR]<$CMDPROMPT.ICO>^>
        <$ExtnAction NewMenu="Y" Key="Open" Description="CMD PROMPT" Command=^"%COMSPEC%" /K ""[INSTALLDIR]<$NewCmdPrompt.cmd_SHORT_NAME>" "%1""^>
        <$ExtnAction             Key="Open" Description="CMD PROMPT" Command=^"%COMSPEC%" /K echo OOPS: The file extension ".<$NEW_CMD_PROMPT_KEY>" isn't expected to exist (however windows needs this or it won't display the new menu option) & pause^>
    <$/Extn>
<$/Component>


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]: TryMeExcelAddIn.MM[Next]: TryMeShortcuts.MM


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.