Powered By Blogger

Wednesday, August 6, 2014

Customized Logs for msi

For writing customized Logging in default msi logs.
You can implement this using either a vb script or an installscript.
Below is a sample log which I created in between creating IIS WEBSITE and APP using APPCMD.

MSI (s) (A0:98) [11:02:47:417]: Hello, I'm your 32bit Impersonated custom action server.
Action start 11:02:47: callthis.
Custom Log: 7/11/2014 11:02:47 AM : Creating Site TestThisSite...
Custom Log: 7/11/2014 11:02:51 AM : Creating App WebUI under Site TestThisSite...
MSI (s) (A0:6C) [11:02:51:472]: Doing action: FindRelatedProducts
Action ended 11:02:51: callthis. Return value 0.

All you want to do is to include the below Function in your code.

InfoMessage “Here is my log”

Sub InfoMessage (MsgText)
            Const msiMessageTypeInfo = &H04000000
            Set oRec = session.Installer.createRecord(1)
            oRec.StringData(0) = "Custom Log: " & Now() & " : [1]"
            oRec.StringData(1) = MsgText
            Session.Message msiMessageTypeInfo, oRec
            Set oRec = Nothing
End Sub

Resolved: Cannot connect to WMI provider. You do not have permission or the server is unreachable

Open cmd as administrator:
Run MOF Compiler by passing below parameter as:

mofcomp "%programfiles%\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"


what is MOFcomp: 
The Managed Object Format (MOF) compiler parses a file containing MOF statements and adds the classes and class instances defined in the file to the WMI repository. MOF files are usually automatically compiled during the installation of the systems with which they are provided, but you can also compile MOF files by using this tool.

Microsoft SQL Server 2012       110
Microsoft SQL Server 2008 R2  100
Microsoft SQL Server 2008       100
Microsoft SQL Server 2005       90

Open services.msc
Restart Windows management Instrumentation WMI Service