Syusaku Takara
Posts: 14
Joined: Mon Nov 02, 2009 1:52 pm

How to display a message on "run log" tab from vbscript?

Hi guys

I want to display a some messages while my script is running for debugging.
Please let me know a proper vbs method to output a message into "run log" tab.

Regards,
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to display a message on "run log" tab from vbscript?

Hello,

The following VBScript writes to log:

Code: Select all

Function WriteToLog
  ' constant taken from
  ' http://msdn.microsoft.com/en-us/library/aa371672%28VS.85%29.aspx
  Const msiMessageTypeInfo = &H04000000
  
  ' create the record for the message
  Set msgRec = Installer.CreateRecord(1)

  ' first field is the message templatetemplate
  msgRec.StringData(0) = "Loging from vbscript: [1]"
  
  ' get the message that is to be written to the log
  dim message  
  message = CStr(Session.Property("CustomActionData"))
  
  ' the second field holds the value to be placed in [1] placeholder
  msgrec.StringData(1) = message
  
  ' send message to running installer
  Session.Message msiMessageTypeInfo, msgrec
  
  ' return success
  WriteToLog = 0
End Function
 
Place it in a vbscript and add it as an attached custom action. Place your message in the custom action data field.
Alternately, you can adapt the function to suit your needs and use it in your vbscripts.

Let me know if this helped.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Syusaku Takara
Posts: 14
Joined: Mon Nov 02, 2009 1:52 pm

Re: How to display a message on "run log" tab from vbscript?

Dear GabrielBarbu

Thank you very much!!
This is exactly match what I want to do.
This should be added into Tips document.

Thanks and Regards,

Return to “Common Problems”