PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: Examples[Next]: Creating HTML pages from Windows URL Shortcuts or OS/2 URL Objects

Wise Installer OLE Automation

I wanted to be able to create MSI (Windows Installer) packages by defining a simple script and processing this via command line tools that could be run via a make file or simply a batch file.

I found that Wise installer supports OLE automation. I did a bit of research and created a header file which will generate a Visual Basic Script (VbScript) which when executed will create an MSI installer package from scratch (no template required).

The defined macros currently support:

Other stuff not currently supported can be added via more macros or simply via inline VbScript. Unless you wish to add inline VbScript you do not need to have any knowledge of this language.

There is no need to ever use the wizard although it can be handly to confirm the approach you are using or for debugging your script. Another reason is to examine the tables that wise uses so you know how to update them from the script.

If you have many projects you will find that even though these scripts are simple, 90% of what they do is common between them and a bit of tweeking will quickly get your second, third or hundredth script going in no time. Nothing is hidden by the wizard, code and changes can be commented and PVCS and other standard difference like tools can be used.

In future I plan on creating a de-compiler (disassembler) for MSI/WSI files so that you can take existing packages and create a script from this (it would probably need tweeking to make more readable but should work OK without the tweeking).

Sample Script to build a MSI Package

This is the sample script I was using for my testing. It produces a perfectly executing MSI package that correctly installs and uninstalls:

    ;----------------------------------------------------------------------------
    ;
    ;    MODULE NAME:   WISETEST.WI
    ;
    ;        $Author:   USER "Dennis"  $
    ;      $Revision:   1.1  $
    ;          $Date:   19 Jan 2001 19:03:18  $
    ;       $Logfile:   C:/DBAREIS/Projects.PVCS/MultiOs/PPWIZARD/WiseTest.wi.pvcs  $
    ;
    ;    DESCRIPTION:   This is a simple test script which does automatically
    ;                   produce a valid wise installer generated "MSI" package.
    ;
    ;                   As a test script it does things I would normally not do,
    ;                   for example, I would not normally hard code version
    ;                   numbers or similar variable information in the script,
    ;                   I would either pass this information as a parameter or
    ;                   I would extract the information from a known location.
    ;
    ;                   No VB knowledge is required, however nothing prevents you
    ;                   imbedding VbScript if I have not yet implemented a
    ;                   feature!
    ;
    ;                   To build (uses PPWIZARD - free preprocessor):
    ;
    ;                      REM *** Convert script into VB code ******************
    ;                      ppwizard WISETEST.wi /output:out\*.vbs /other /dependson:out\*.dep /define:WISEWSI=c:\tmp\WISETEST.wsi /errorfile:out\ppwizard.err
    ;
    ;                      REM *** Execute VB code to create MSI package ********
    ;                      if not errorlevel 1 cscript out\WISETEST.vbs
    ;
    ;                   PPWIZARD is the most powerful preprocessor available
    ;                   AND IT'S FREE (personal or commercial use),
    ;                   it's homepage is at:
    ;
    ;                       http://www.labyrinth.net.au/~dbareis/ppwizard.htm
    ;
    ;----------------------------------------------------------------------------
    
    ;--- Include PPWIZARD WISE INSTALLER OLE AUTOMATION support -----------------
    ;#define  NO_POPUP_ON_TRAP          ;;Option: Want popup on trap
    ;#define  NO_POPUP_ON_ERROR         ;;Option: Want popup when error detected
    #define  DEBUG_OUTPUT              ;;Option: Macros display text
    #include "WISEINST.WIH"
    
    ;--- Define some global variables -------------------------------------------
    #define ProductName     PPWIZARD
    #define ProductVersion  20.00.355
    #define ProductAuthor   Dennis Bareis - <$BSD>
    #define ProductDir      Program Files\PPWIZARD_W
    #define ShortCutDir     <$STARTBAR_PGM_DIR>\PPWIZARD_W
    
    ;--- Start Install Package --------------------------------------------------
    <$Package>
    
    ;--- Load a template --------------------------------------------------------
    ;<$LoadTemplate FILE="C:\tmp\Test InstallShield\2dump.wsi">
    
    ;--- Set some properties ----------------------------------------------------
    <$SetProperty NAME="ProductName"    VALUE="<$ProductName>">
    <$SetProperty NAME="ProductVersion" VALUE="<$ProductVersion>">
    <$SetProperty NAME="Author"         VALUE="<$ProductAuthor>">
    <$SetProperty NAME="Manufacturer"   VALUE=^<$ProductAuthor> - Test " <- double quote^>
    
    ;--- Update PATH (system/at end) --------------------------------------------
    <$Path  PATH="c:\at\end\system">
    
    ;--- Update PATH (user/at start) --------------------------------------------
    <$Path                                       \
           PATH="c:\at\start\user"               \
           SYSTEM="N"                            \
           ATEND="N"                             \
    >
    
    ;--- Set another "PATH" like variable ---------------------------------------
    <$Path                                        \
           NAME="REGINA_MACROS"                   \
           PATH="c:\at\end\reginamacros"          \
    >
    
    
    
    ;--- Add files to "COMPLETE" ------------------------------------------------
    <$AddFile                                                   \
                SOURCE="c:\winnt\system32\notepad.exe"          \
           DESTINATION="Program Files\PPWIZARD_W\notepad.exe"   \
    >
    
    
    ;**      CommentBlock  /* (Thursday 21/12/2000, 13:39:45, by Dennis Bareis) */
    ;**+--------------------------------------------------------------------------
    ;**|;--- Load all files (including from subdirectories) -------------------------
    ;**|<$AddFiles                                                    \
    ;**|               SrcDir="C:\tmp\Test InstallShield\PPWIZARD"    \
    ;**|              DestDir="Program Files\PPWIZARD_W"              \
    ;**|>
    ;**+--------------------------------------------------------------------------
    ;**                    /* (Thursday 21/12/2000, 13:39:45, by Dennis Bareis) */
    
    
    ;--- Create a shortcut to the doco ------------------------------------------
    <$AddShortCut                                                  \
                    Title="Test PPWIZARD_W Shortcut"               \
                    ScDir="<$ShortCutDir>"                         \
                 ScTarget="<$ProductDir>\PPW_DOCO\ppwizard.htm"    \
                   ScDesc="A test short cut to ppwizard doco"      \
                   ScType="<$FOR_CMDLINE>"                         \
    >
    
    
    ;--- Set registry key -------------------------------------------------------
    <$AddRegValue                               \
           HKEY="<$CURRENT_USER>"               \
        KeyPath="Software\ANZ\PPWIZARD_W"       \
      ValueName="TestPPWIZARDKEY"               \
          Value="TestPPWIZARDVALUE"             \
    >
    
    ;--- Add a feature ----------------------------------------------------------
    <$AddFeature NAME="FeatureDB" DestDir="C:\tmp\FEATUREDB">
    <$AddFile                                                   \
                SOURCE="c:\winnt\system32\notepad.exe"          \
           DESTINATION="Program Files\PPWIZARD_W\notepad.exe"   \
           Add2="FeatureDB"                                     \
    >
    
    ;--- Add a component --------------------------------------------------------
    <$AddComponent NAME="Fred"  DestDir="C:\tmp\freddir">
    <$AddComponent NAME="Fredx" DestDir="C:\tmp\fredxdir" FEATURE="FeatureDB">
    
    
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    '%%%[ You would probably rarely if ever want to do the following) %%%%%%%%%%%
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    
    ;--- Create some NEW table rows ---------------------------------------------
    <$TABLE "Environment">
       <$Row                                                  \
           Environment="NewRow1"                              \
                  Name="NEWR1"                                \
                 Value='ValueContains"DoubleQuote'            \
            Component_="Registry"                             \
       >
       <$Row                                                  \
           Environment="NewRow2"                              \
                  Name="*=-NEWR2"                             \
                 Value="[~];c:\NewR1"                         \
            Component_="Registry"                             \
       >
    <$/TABLE>
    
    ;--- Change 1 field of 2 records --------------------------------------------
    <$TABLE "TextStyle">
       <$Row "Arial10" Size=24>
       <$Row "Arial12" Size=26>
    <$/TABLE>
    
    ;--- Update Text for error #1 -----------------------------------------------
    <$TABLE "Error"><$Row "1" Message="My Error Text for Message #1 - [1]"><$/TABLE>
    
    ;--- End   Install Package (compile) ----------------------------------------
    <$/Package>
    
    
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    'Note that if you were using your own imbedded VB you can place any common
    'functions etc here (after end of package)
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    

While the above is good for testing, in real life I would have things slightly different, for example I would either pick up the version number by reading a file or pass it using the "/define" switch.

I would never want to modify the script unless the packaging requirements changed.

The Header File - WISEINST.WIH

This is the header file that is included in the above script, you would never touch this file apart from adding macros etc to make scripts like the above easier to write.

The header file is not documented so for that reason only a person writing a script would need to refer to the file:

    ;----------------------------------------------------------------------------
    ;
    ;    MODULE NAME:   WISEINST.WIH
    ;
    ;        $Author:   USER "Dennis"  $
    ;      $Revision:   1.4  $
    ;          $Date:   19 Jan 2001 19:03:18  $
    ;       $Logfile:   C:/DBAREIS/Projects.PVCS/MultiOs/PPWIZARD/wiseinst.wih.pvcs  $
    ;
    ;    DESCRIPTION:   Provides a script like OLE AUTOMATION SUPPORT for
    ;                   wise installer.
    ;
    ;                   Do NOT touch this file it is included by your script!
    ;
    ;                   No VB knowledge is required.
    ;
    ;                   To build (uses PPWIZARD - free preprocessor):
    ;
    ;                      REM *** Convert script into VB code ******************
    ;                      ppwizard WISETEST.wi /output:out\*.vbs /other /dependson:out\*.dep /define:WISEWSI=c:\tmp\WISETEST.wsi /errorfile:out\ppwizard.err
    ;
    ;                      REM *** Execute VB code to create MSI package ********
    ;                      if not errorlevel 1 cscript out\WISETEST.vbs
    ;
    ;                   PPWIZARD is the most powerful preprocessor available
    ;                   AND IT'S FREE (personal or commercial use),
    ;                   it's homepage is at:
    ;
    ;                       http://www.labyrinth.net.au/~dbareis/ppwizard.htm
    ;
    ;        WARNING:   It is early days for this script (and my knowledge)
    ;                   so things will probably change for future versions
    ;                   of this header. Always back up any existing scripts
    ;                   as well as older versions of ppwizard and this header
    ;                   before upgrading.
    ;----------------------------------------------------------------------------
    
    
    ;--- Define Version number of this install support --------------------------
    #ifdef  WISEINST_VERSION
            #eof 1;                ;;Don't process again if included twice!
    #endif
    #define WISEINST_VERSION   01.008
    #Option PUSH DefineMacroReplace=ON
    #define WISEINST_HEADER    <?InputComponent>
    #Option POP
    
    ;--- Make sure user specified the name of the output file -------------------
    #ifndef WISEWSI
            #error ^The define "WISEWSI" must contain name of output WISE package^
    #endif
    
    ;--- Define our group -------------------------------------------------------
    #define BSD   ANZ - Australia - Branch Systems Development - (03)9658-1409
    
    ;--- Default feature --------------------------------------------------------
    #define Complete           Complete            ;;Default Feature Name
    
    ;--- WISE HKEY TYPES --------------------------------------------------------
    #define CURRENT_USER_PUI   -1
    #define CLASSES_ROOT        1
    #define CURRENT_USER        2
    #define LOCAL_MACHINE       3
    #define USERS               4
    
    ;--- WISE REGISTRY KEY TYPES ------------------------------------------------
    #define STRING              0
    #define EXPANDABLE_STRING   1
    #define INTEGER             2
    #define BINARY              3
    
    ;--- WISE ADD KEY OPERATION TYPES -------------------------------------------
    #define CREATED_IF_MISSING  1
    #define CREATED_...More
    
    ;--- Add to Component or Feature --------------------------------------------
    #define FEATURE               0
    #define COMPONENT             1
    
    ;--- How to add wildcard files from directory -------------------------------
    #define NO_SUBDIRECTORIES          0
    #define SUBDIRECTORIES             1
    #define UPDATE_NEW_COMPONENTS      2
    
    ;--- Shortcut types ---------------------------------------------------------
    #define ADVERTISED     1
    #define FOR_FILE       2
    #define FOR_CMDLINE    3
    
    ;--- Define some directory location -----------------------------------------
    #define DESKTOP_DIR        Windows\Profiles\Desktop
    #define STARTBAR_DIR       Windows\Profiles\Start Menu
    #define STARTBAR_PGM_DIR   <$STARTBAR_DIR>\Programs
    
    ;--- Define some window sizes (for shortcuts) -------------------------------
    #define NORMAL         0
    #define MINIMISED      7
    #define MAXIMISED      3
    #define MINIMIZED      <$MINIMISED>
    #define MAXIMIZED      <$MAXIMISED>
    
    
    ;--- Set default for trap detection handler ---------------------------------
    #ifdef DEBUG_OUTPUT
           ;--- No runtime trap handler if debugging (VB is too stupid!) --------
           #define? RUNTIME_TRAPS_DETECTED N
    #elseif
           ;--- In "Production" mode probably want trap detection ---------------
           #define? RUNTIME_TRAPS_DETECTED Y
    #endif
    
    ;--- Start/end of Install script --------------------------------------------
    #define Package   <$VBSCRIPT_AT_START>
    #define /Package  <$VBSCRIPT_AT_END>
    
    ;--- Create VbScript string literals ----------------------------------------
    
    ;--- Define 'X' codes that can be used within VB "literal" strings ----------
    #DefineRexx ''
       do  Ascii = 0 to 255
           ;--- This code is only to be used within a VB STRING (double quoted) ---
           VbCode = '" & chr(' || Ascii || ') & "'
    
           ;--- Set up the code -------------------------------------------------
           call SetXCode d2x(Ascii), VbCode
       end;
       call SetXCode "DQ",   '" & chr(' || c2d('"') || ') & "'
       call SetXCode "CRLF", '" & vbCRLF & "'
       call SetXCode "CR",   '" & vbCR & "'
       call SetXCode "LF",   '" & vbLF & "'
    #DefineRexx
    #DefineRexx REXX_$$VBSTR
                ;--- Handle user entering double quotes in a value --------------
                TheValue = '"' || ReplaceString(TheValue, '"', '<?xDQ>') || '"';
    #DefineRexx
    
    ;--- Used to remember location in code (make up for stupid VB deficiency) ---
    #DefineRexx REXX_$$SHORT
                ;--- Transformation to return short name given one with path ----
                TheValue = _filespec('name', TheValue);
    #DefineRexx
    #OneLine   '<?NewLine>'
       #define HereWeAre
               ;--- Set a global variable to hold information -------------------
               HereWeAre = "<?InputComponent $$SHORT>(<?InputComponentLine>){$#1=^^ $$SPCPLUS}"
    
               ;--- Display Information on console ------------------------------
               #ifdef DEBUG_OUTPUT
                      Say "@<?InputComponentLine>: {$#1=^^ $$SPCPLUS}"
               #endif
    #OneLineEnd
    
    
    
    ;--- Useful Macros (use if you write imbedded VbSCript!) --------------------
    #define WiseObj         WiseObj                ;;In case interface completely changes...
    #define DieIfKeyInvalid KeyMustBeOk(Key)
    #define DieIfNotOk      BoolMustBeTrue(Ok)
    
    
    ;--- Wise Hide compile dialog box -------------------------------------------
    #define HideCompileDialogBox        \
            <$HereWeAre "{$MacName}">  %\
            <$WiseObj>.SetSilent
    
    ;--- Set properties ---------------------------------------------------------
    #OneLine   '<?NewLine>'
       #define SetProperty
               <?NewLine><$HereWeAre "{$?MacName} - {$Name}">
               Ok = <$WiseObj>.SetProperty("{$Name}", {$Value $$VBSTR})
               <$DieIfNotOk>
    #OneLineEnd
    
    ;--- Set Load Template ------------------------------------------------------
    #OneLine   '<?NewLine>'
       #define LoadTemplate
               <?NewLine><$HereWeAre "{$?MacName} - {$File}">
               Ok = <$WiseObj>.Open("{$File}")
               <$DieIfNotOk>
    #OneLineEnd
    
    ;--- Add Feature ------------------------------------------------------------
    #define FDISP_INVISIBLE                                 0
    #define FDISP_VISIBLE_AND_EXPANDED                      1
    #define FDISP_VISIBLE_AND_COLLAPSED                     2
    #define FILVL_NEVER_INSTALL                             0
    #define FILVL_ALWAYS_INSTALL                            1
    #define FILVL_NORMAL                                    3
    #define FATTR_FAVOR_SOURCE_INSTALL                      1
    #define FATTR_FAVOR_PARENT_ATTRIBUTES                   2
    #define FATTR_FAVOR_ADVERTISED_FEATURE                  4
    #define FATTR_DISALLOW_ADVERTISING                      8
    #define FATTR_DISALLOW_OPT_TO_SET_ABSENT               16
    #define FATTR_DISALLOW_ADVERTISED_IF_OPSYS_WONT_ALLOW  32
    #define FATTR_DEFAULT                                   0
    #define AddFeature                                               \
            <?NewLine><$HereWeAre "{$?MacName} - '{$Name}' to '{$Parent=^^}'"> %\
            Ok = <$WiseObj>.AddFeature(                              \
                  "{$Name}",                                         \
                  "{$Parent}",                                       \
                  "{$Title=^LINE_<?InputComponentLine>^}",           \
                  "{$Description=^LINE_<?InputComponentLine>^}",     \
                  {$Display=^<$FDISP_VISIBLE_AND_COLLAPSED>^},       \
                  {$Level=^<$FILVL_NORMAL>^},                        \
                  "{$DestDir}",                                      \
                  {$Attributes="<$FATTR_DEFAULT>"}                   \
            )                                                       %\
            <$DieIfNotOk>
    
    ;--- Add Component ----------------------------------------------------------
    #define CATTR_CANT_RUN_FROM_SOURCE       0
    #define CATTR_ONLY_RUN_FROM_SOURCE       1
    #define CATTR_RUN_FROM_SOURCE_OR_LOCAL   2
    #define CATTR_KEY_PATH_FOR_REGISTRY      4
    #define CATTR_INC_SHARED_DLL_COUNT       8
    #define CATTR_NOT_REMOVE_AT_UNINSTALL    16
    #define CATTR_KEY_PATH_FOR_ODBC          32
    #define CATTR_COMPONENT_IS_TRANSITIVE    64
    #define CATTR_NEVER_OVERWRITE            128
    #define AddComponent                                             \
            <?NewLine><$HereWeAre "{$?MacName} - '{$Name}' to '{$Feature="<$Complete>"}'"> %\
            Ok = <$WiseObj>.AddComponent(                            \
                  "{$Name}",                                         \
                  "{$DestDir}",                                      \
                  "{$CONDITION=^^}",                                 \
                  {$Attributes="<$CATTR_CANT_RUN_FROM_SOURCE>"}      \
            )                                                       %\
            <$DieIfNotOk>                                           %\
            Ok = <$WiseObj>.AddComponentToFeature(                   \
                  "{$Name}",                                         \
                  "{$FEATURE}"                                       \
            )                                                       %\
            <$DieIfNotOk>
    
    ;--- Add file ---------------------------------------------------------------
    #define AddFile                                                  \
            <?NewLine><$HereWeAre "{$?MacName} - {$SOURCE}">        %\
            Key = <$WiseObj>.AddFileEx(                              \
                  "{$SOURCE}",                                       \
                  "{$DESTINATION}",                                  \
                  {$Attributes="0"},                                 \
                  "{$Add2="<$Complete>"}", ;;Feature/Component name  \
                  {$Add2Type="<$FEATURE>"},                          \
                  PvComponent                                        \
            )                                                       %\
            <$DieIfKeyInvalid>
    
    ;--- Add files (wildcard)----------------------------------------------------
    #define AddFiles                                                 \
            <?NewLine><$HereWeAre "{$?MacName} - {$SrcDir}">        %\
            Key = <$WiseObj>.AddWildcard(                            \
                  "{$FEATURE="<$Complete>"}",                        \
                  {$CONDITION=^^  $$VBSTR},                          \
                  "{$Includes=^*.*^}",     ;;Delimiter = ";"         \
                  "{$Excludes=^^}",        ;;Delimiter = ";"         \
                  "{$SrcDir}",                                       \
                  "{$DestDir}",                                      \
                  {$How="<$SUBDIRECTORIES>"},                        \
                  {$CompAttr="<$CATTR_CANT_RUN_FROM_SOURCE>"}        \
            )                                                       %\
            <$DieIfKeyInvalid>
    
    
    ;--- Add Registery Value ----------------------------------------------------
    #define AddRegValue                                              \
            <?NewLine><$HereWeAre "{$?MacName} - {$ValueName}">     %\
            Key = <$WiseObj>.AddRegistryValueEx(                     \
                  {$HKEY},                                           \
                  "{$KeyPath}",                                      \
                  "{$ValueName}",                                    \
                  {$Value  $$VBSTR},                                 \
                  {$Type="<$string>"},                               \
                  {$HOW="<$CREATED_IF_MISSING>"},                    \
                  "{$Add2="<$Complete>"}", ;;Feature/Component name  \
                  {$Add2Type="<$FEATURE>"},                          \
                  PvComponent                                        \
            )                                                       %\
            <$DieIfKeyInvalid>
    
    
    ;--- Add Shortcut -----------------------------------------------------------
    #define AddShortCut                                                       \
            <?NewLine><$HereWeAre "{$?MacName} - {$Title}">                  %\
            Key = <$WiseObj>.AddShortCutEx(                                   \
                  {$ScType=^<$FOR_CMDLINE>^},                                 \
                  "{$ScTarget=^^}",                 ;;Not required if ADVERT  \
                  "{$AdvAdd2="<$Complete>"}",       ;;Feature name            \
                  {$Title $$VBSTR},                 ;;Shortcut's Name         \
                  "{$ScDir=^<$STARTBAR_PGM_DIR>^}", ;;Create where?           \
                  "{$ScArgs=^^}",                   ;;Shortcut's arguments    \
                  "{$ScDesc=^^}",                   ;;Shortcut's description  \
                  "{$ScWorkDir=^^}",                ;;Shortcut's work dir     \
                  {$ScHotKey=^0^},                  ;;Shortcut's hot key      \
                  {$ScWinSize=^<$NORMAL>^},         ;;Shortcut's Window size  \
                  {$ScIconNumb=^0^},                ;;Icon # in EXE           \
                  "{$Add2="<$Complete>"}",          ;;Feature/Component name  \
                  {$Add2Type="<$FEATURE>"},         ;;Feature or Component?   \
                  PvComponent                                                 \
            )                                                                %\
            <$DieIfKeyInvalid>
    
    
    ;--- Update PATH (type variables) -------------------------------------------
    #define    ENV_CREATE_WHEN_INSTALLED
    #define    ENV_DELETE_ON_INSTALL       !
    #define    ENV_DELETE_ON_UNINSTALL     -
    #define    ENV_CREATE_IF_NONEXISTANT   +
    #OneLine   '<?NewLine>'
       #define Path
               ;--- Work out the modifier required for the env vars location ----
               #if ['{$SYSTEM=^Y^}' = 'Y']          -\
                   #define+ ENV_SYS  *              -\
               #elseif                              -\
                   #define+ ENV_SYS                 -\
               #endif                               -\
    
               ;--- How is variable updated -------------------------------------
               #if ['{$ATEND=^Y^}' = 'Y']           -\
                   #define+ ENV_POS  [~];{$PATH}    -\
               #elseif                              -\
                   #define+ ENV_POS  {$PATH};[~]    -\
               #endif                               -\
    
               ;--- Point to The Environment TABLE ------------------------------
               <$HereWeAre "{$?MacName}">
               Set TableEnvironment = <$WiseObj>.WTables("Environment")
    
               ;--- Add Details to the table (create new row) -------------------
               set Row = TableEnvironment.NewWRow()
               Row("Environment") = "{$Key=^LINE_<?InputComponentLine>^}"
               Row("Name")        = "<$ENV_SYS>={$HOW=^<$ENV_DELETE_ON_UNINSTALL>^}{$NAME=^PATH^}"
               Row("Value")       = "<$ENV_POS>"
               Row("Component_") = "{$Component=^Registry^}"
    #OneLineEnd
    
    ;--- Define TABLE -----------------------------------------------------------
    #RexxVar InTable = ''
    #define /Table                                                              \
            #RexxVar InTable = ''
    #define Table                                                               \
            ;--- Make sure not already in a table ---                          -\
            #if ['<??InTable>' <> '']                                          -\
                #Error ^Already in table "<??InTable>" started at <??InTableStarted>^  -\
            #endif                                                             -\
                                                                               -\
            ;--- OK, remember details ---------------                          -\
            #RexxVar InTableStarted = ^<?=GetInputFileNameAndLine()>^          -\
            #RexxVar InTable        = ^{$#1}^                                  -\
                                                                               -\
            ;--- Now generate VbScript to access table ---                     -\
            <?NewLine>                                                         -\
            <$HereWeAre =^{$?MacName} - Table '{$#1}'^>                        %\
            set CurrentTable = <$WiseObj>.WTables("{$#1}")   ;;Generates runtime error if table does not exist  %\
            set CurrentRows  = CurrentTable.WRows()<?NewLine>
    #define MustBeWithinTableMacro                                    \
            ;--- Make sure not already in a table ---                -\
            #if ['<??InTable>' = '']                                 -\
                #Error ^You must be in a table to use this macro!^   -\
            #endif
    
    ;--- Update/Create Row Macro ------------------------------------------------
    #define Row                                                                 \
            ;--- Generate code to create a new row ---                         -\
            <$MustBeWithinTableMacro>                                          -\
            <?NewLine>                                                         -\
            #if    ['{$#1=^!NEW!^}' = '!NEW!']                                 -\
                   <$HereWeAre =^{$?MacName} - New Record^>                    %\
                   set CurrentRow  = CurrentTable.NewWRow()                    %\
            #elseif                                                            -\
                   <$HereWeAre =^{$?MacName} - KEY='{$#1}'^>                   %\
                   set CurrentRow = CurrentRows.Row("{$#1}")                   %\
            #endif                                                             -\
                                                                               -\
            ;--- Generate code to initialize fields/columns ---                -\
            #evaluate ^^ ^<$RexxUpdateColumns {$?}>^                           -\
            <??VbCode>     ;;Invalid Field name will cause runtime error
    #DefineRexx RexxUpdateColumns
                ;--- Create rexx stem from passed information -------------------
                {$??}        ;;Allows access to ROW/VALUE information
    
                ;--- Now Create VB code to update the supplied columns ----------
                VbCode = '';
                do Field = 1 to MP.0
                   VbCode = VbCode || 'CurrentRow("' || MP.Field.MpName || '") = "' || ReplaceString(MP.Field.MpValue, '"', '""') || '"<?x0A>'
                end;
    #DefineRexx
    
    ;--- Delete all current records in table ------------------------------------
    #define DeleteAllRows                                                       \
            ;--- Generate code to create a new row ---                         -\
            <$MustBeWithinTableMacro>                                          -\
            <?NewLine><$HereWeAre "{$?MacName}">                               %\
            for each CurrentRow in CurrentRows                                 %\
                CurrentRows.Delete CurrentRow, FALSE                           %\
            next
    
    
    ;----------------------------------------------------------------------------
    ;--- The following Code should be at START of generated code ----------------
    ;----------------------------------------------------------------------------
    #OneLine '<?NewLine>'
       ;--- Define name of macro ------------------------------------------------
       #define VBSCRIPT_AT_START
    
               '----------------------------------------------------------------
               ' This file was automatically produced by PPWIZARD.
               '
               ' PPWIZARD is a FREE product (private or commercial),
               ' available from:
               '
               '      <?PpwizardHomePage>
               '
               ' Apart from possiblity doing some debugging do not modify this
               ' file as your changes will get lost when the file is
               ' regenerated.
               '
               '
               ' DETAILS
               ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               ' Generated   : <?OutputFile>
               ' At          : <?CompileTime>
               ' Source      : <?InputComponent>
               ' Header      : <$WISEINST_HEADER>
               ' Header VER  : <$WISEINST_VERSION>
               ' PPWIZARD    : <?PpwizardPgm>
               ' PPWIZARD VER: <?Version>
               '
               '----------------------------------------------------------------
    
               ;--- Require all used variables to be defined --------------------
               <?NewLine>
               Option Explicit
    
               ;--- Define some global variables --------------------------------
               dim <$WiseObj>
               dim TableEnvironment         ;;Used by PATH   macro
               dim CurrentTable             ;;Used by TABLE  macros
               dim CurrentRows, CurrentRow  ;;Used by ROW macros
               dim Row
               dim PvComponent
               dim HereWeAre
               dim Key, Ok
               dim NL, NP
               NL = chr(10) & chr(13)
               NP = NL & NL
    
               ;--- Call mainline() ---------------------------------------------
               #if ['<$RUNTIME_TRAPS_DETECTED>' = 'N']
                   ;--- Execute code (never returns) ----------------------------
                   #ifdef DEBUG_OUTPUT
                       Say  "As Per your request there was no trap handler added!"
                   #endif
                   MainLine()
               #elseif
                   ;--- Define error handler ------------------------------------
                   On error resume next
    
                   ;--- Execute code (never returns) ----------------------------
                   MainLine()
    
                   ;--- If we get here we had a runtime error (display the error) ---
                   Say ""
                   Say "VBSCRIPT TRAP Detected"
                   Say "~~~~~~~~~~~~~~~~~~~~~~"
                   Say "Error Number: " & CStr(Err.Number)
                   Say "Desc        : " & Err.Description
                   Say "Near        : " & HereWeAre
                   Say "In Script   : " & WScript.ScriptFullName
                   Say "Detected by : " & Err.Source
    
                   ;--- Do we want a message box as well? -----------------------
                   #ifndef NO_POPUP_ON_TRAP
                           dim Text, Title
                           Title = "TRAP IN " & WScript.ScriptName
                           Text  = "Error # " & CStr(Err.Number) & " " & Err.Description & NP & "Error occurred near " & HereWeAre
                           MsgBox Text, vbCritical, Title
                   #endif
               #endif
    
               ;--- Trap EXIT ---------------------------------------------------
               Wscript.Quit 218
    
               ;--- Define start of Mainline ------------------------------------
               <?NewLine>
               <?NewLine>
               Sub MainLine
    
               ;--- Connect to Wise for Windows Installer object ----------------
               <?NewLine>
               <$HereWeAre "{$?MacName}">
               Say "Creating Wise Document"
               Set <$WiseObj> = Nothing
               Set <$WiseObj> = Wscript.CreateObject("WfWi.Document")
    
               ;--- Make MSI ----------------------------------------------------
               #define NEWT_INSTALLER_DB_PROJECT 1
               #define NEWT_MERGE_MODULE_PROJECT 3
               Ok = <$WiseObj>.NewEx({$TYPE="<$NEWT_INSTALLER_DB_PROJECT>"}, {$WANTPRJFILE="TRUE"})
               <$DieIfNotOk>
               <?NewLine>
               <?NewLine>
    #OneLineEnd
    
    
    ;----------------------------------------------------------------------------
    ;--- The following Code should be at END of generated code ------------------
    ;----------------------------------------------------------------------------
    #OneLine '<?NewLine>'
       ;--- Define name of macro ------------------------------------------------
       #define VBSCRIPT_AT_END
    
               ;--- Now produce WSI/MSI Files -----------------------------------
               <?NewLine>
               <$HereWeAre "{$?MacName}">
               Say "Generating: <$WISEWSI>"
               Ok = <$WiseObj>.Save("<$WISEWSI>")
               <$DieIfNotOk>
               Ok = <$WiseObj>.Compile("<$WISEWSI>")
               <$DieIfNotOk>
               Wscript.Quit 0
    
    
               ;--- Define end of Mainline() ------------------------------------
               End Sub 'Mainline
    
               ;--- We are about to die because of an invalid return code -------
               <?NewLine>
               <?NewLine>
               <?NewLine>
               Sub Say(What)
                   Wscript.Echo What
               end sub
               <?NewLine>
               Sub Die()
                   ;--- Output a header -----------------------------------------
                   Say ""
                   Say "Error Detected"
                   Say "~~~~~~~~~~~~~~"
    
                   ;--- Output the WISE return code -----------------------------
                   Say "Near    : " + HereWeAre
                   Say "Wise Rc : " + <$WiseObj>.GetLastError()
    
                   ;--- Display a popup unless user doesn't want one ------------
                   #ifndef NO_POPUP_ON_ERROR
                       dim Text, Title
                       Title = "ERROR IN " & WScript.ScriptName
                       Text  = "Wise reports: " & <$WiseObj>.GetLastError() & NP & "Error occurred near " & HereWeAre
                       MsgBox Text, vbCritical, Title
                   #endif
    
                   ;--- Simply exit ---------------------------------------------
                   Wscript.Quit 219
               end sub
    
               ;--- Checks "KEY" return codes -----------------------------------
               <?NewLine>
               Sub KeyMustBeOk(ThisMustBeNonBlank)
                   if  ThisMustBeNonBlank = "" then
                       Die()
                   end if
               end sub
    
               ;--- Checks Boolean return codes ---------------------------------
               <?NewLine>
               Sub BoolMustBeTrue(ThisMustBeTrue)
                   if  not ThisMustBeTrue  then
                       Die()
                   end if
               end sub
    #OneLineEnd
    


[Top][Contents][Search][Prev]: Examples[Next]: Creating HTML pages from Windows URL Shortcuts or OS/2 URL Objects

PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Monday January 22 2001 at 5:44pm