Monday, November 17, 2008

Script custom action notes


Unsorted notes related to VBScript and JScript custom actions (assuming the world can’t talk you out of it):

  • Use CreateObject, not WScript.CreateObject.
  • Use Session.Property (or just plain Property) to get and set properties from a custom action:
    ' VBScript:
    Session.Property("USERNAME") = "Valued Customer" ' value must be a string
    MsgBox "Hello, " & Session.Property("USERNAME")
  • For Directory-table properties, use Session.TargetPath("CaseSensitivePropertyName")
  • Session.Property in a deferred custom action requires use of CustomActionData.
  • If you want to catch the return value from a script function, the script code must be stored in a file, and not in the CustomAction table.
  • Script custom actions cannot be run asynchronously. (I found this out only recently when I was experimenting with SpawnWaitDialog, about which more later.)

No comments: