John McFadyen's profileJohn McFadyens Windows I...PhotosBlogGuestbookMore ![]() | Help |
|
|
April 11 Useful Custom ActionsI have been using these for sometime and only recently realised how often that was.
I thought they may be useful to some of you out there.
A simple little routine to write to the MSI log.
function WriteToMsiLog(strMessage)
Const msiMessageTypeInfo = &H04000000
Set objMessage = session.Installer.CreateRecord(1) objMessage.StringData(0) = "Log: [1]" objMessage.StringData(1) = strMessage if session.property("CUSTDEBUG") <> "" then msgbox "MESSAGE: " & strMessage Session.Message msiMessageTypeInfo, objMessage end function
This is a nice easy way to get some output to your logs. As most of you know I spend more time in the repackaging area as opposed to SDLC solutions as such VBS CA's are more prominent in my current work.
Note: If you pass CUSTDEBUG property during installation you will get debugging feedback messages which are useful during testing of new vbs CustomActions.
How to Format Records such as [#FileKey], [$ComponentKey]
function FormatRecord(strRecordName)
on error resume next
set objInstaller = session.installer set objRecord = objInstaller.CreateRecord(1) objRecord.ClearData objRecord.StringData(0) = strRecordName strFormattedRecord = Session.FormatRecord(objRecord) WriteToMsiLog "MESSAGE: Formatting record key " & strRecordName & vbcr & "Result = " & strFormattedRecord FormatRecord = strFormattedRecord set objRecord = nothing end function This is a handy way to resolve those MSI variables. For those of you setting perms with subinacls or other third party tools (i.e. not the lock permissions table) then you you may well need to use this to ensure your packages stay dynamic. This is particularly common issue amongst the repackagers as path locations are more often than not a static path is acceptable. However in the unlikely chance someone changes and installation path the repackagers would fall victim to failed CA's as paths in the CA's would not exist.
Using a Formatted record and passing that Record value to the deferred phase via CustomActionData would ensure that your packages maintain support for dynamic installation (i.e. variable installation directories)
|
|
|