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]: Custom Action Functions[Next]: VbsCaCadGetValidate()
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->VBSCRIPT->Custom Action Functions->VbsCaCadGet()

VbsCaCadGet()

This function can be called to retrieve a parameter specified with the "DATA" parameter of the "VbsCaSetup" command. It must only be used in deferred custom actions (the information is passed as "CustomActionData"). If your custom action is not deferred you would normally use "VbsCaPropertyGet" instead.

If the parameter does not exist then the function traps.

The VbsCaCadGetVbsCaCadGetValidate() function is similar but also validates the value.

The function takes a single parameter (with 3 meanings):

  1. Value of "?" is Passed
    A dictionary object ("Scripting.Dictionary") containing all keys and values is returned. It is recommended that this form not be used when the others will do so as to reduce the chance of bugs and improve logging.

  2. Value starting with "?:" is Passed
    The name of the #data key you wish to query follows the "?:" characters. The string "Y" is returned if it exists else "N" is. This allows you to implement an optional value since trying to retrieve a value that doesn't exist causes the custom action to abort.

  3. Any other Value is name of #data Key
    The name of a parameter (the first column in the "#data" structure).

TEST MODE

When testing this parameter from a command line the data will not be available and so you will be prompted for the information (for all data variables).

If you have supplied the "DATA" parameter on the "VbsCa" command then it is used to to supply the default data for the prompt. This data will not be perfect as items such as "[INSTALLDIR]" will not have been expanded.

I suggest if you are doing lots of testing that you update the initialization for VBSCRIPT variable "TestCustomActionData" before testing.

EXAMPLE

;--- Set up the 2 parameters (CustomActionData) -----------------------------
#data "Fred"
   "Name1" 'Name 1 Value'          ;;Parameter 1 (name + value)
   "Name2" "[INSTALLDIR]"          ;;Parameter 2
#data

;--- Deferred Custom Action which accesses 2 passed parameters --------------
<$VbsCa Binary="TestCustomActionDataPassing.vbs" DATA="Fred">
   <$VbsCaEntry "Install">
       ;--- Do something ----------------------------------------------------
       Show("Install: NAME1=" & VbsCaCadGet("Name1"))
       Show("Install: NAME2=" & VbsCaCadGet("Name2"))
   <$/VbsCaEntry>

   '=======================
   sub Show(Text)
   '=======================
       CaMsgBox "I", Text
   end sub
<$/VbsCa>

;--- Set up the Deferred custom action passing the CustomActionData ---------
<$VbsCaSetup Data="Fred" Binary="TestCustomActionDataPassing.vbs" Entry="Install" Seq="InstallFiles-" CONDITION=^<$CONDITION_INSTALL_ONLY>^>


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]: Custom Action Functions[Next]: VbsCaCadGetValidate()


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.