Exporting data from an MSI or MST?
Apologies for making a "duplicate" post, but this forum seems to get a lot more eyeball traffic than the Scripting forum.
Does anyone happen to know of any scripts or tools to export/extract specific information from an MSI or MST?
I am definitely not a programmer type. I just use simple VBscript, Winbatch and/or Wisescript for most of the MSI custom actions I need, which is usually enough. However, I currently have a need for something more advanced that can extract and parse specific pieces of MSI/MST data and then pass this data as parameters to another script --or, alternatively-- pipe it into a text file.
kkaminsk located the following code for me:
Export File List to Excel From MSI Using VBScript
http://www.serverwatch.com/tutorials/article.php/1548261
This works, but unfortunately just exports the entire contents of whatever table you specify, including column headers. What I'm looking for is something that allows a lot more precision, specifically the ability to export just the data for a specific column from a table. Also having some ability to parse the data would be helpful too.
For example, I need to know the following:
1. How many shortcuts are in an MSI's shortcut table?
2. What are the long filenames for these shortcuts? ("Name" column value --minus the "SHORTC~1|" part)
3. Where are they being delivered? (what "Directory_" column value resolves to)
Perhaps there is no simple canned vbscript solution for this --I've searched and have yet to find one. Any donated code, or ideas/leads for further research would be greatly appreciated, thanks.
Does anyone happen to know of any scripts or tools to export/extract specific information from an MSI or MST?
I am definitely not a programmer type. I just use simple VBscript, Winbatch and/or Wisescript for most of the MSI custom actions I need, which is usually enough. However, I currently have a need for something more advanced that can extract and parse specific pieces of MSI/MST data and then pass this data as parameters to another script --or, alternatively-- pipe it into a text file.
kkaminsk located the following code for me:
Export File List to Excel From MSI Using VBScript
http://www.serverwatch.com/tutorials/article.php/1548261
This works, but unfortunately just exports the entire contents of whatever table you specify, including column headers. What I'm looking for is something that allows a lot more precision, specifically the ability to export just the data for a specific column from a table. Also having some ability to parse the data would be helpful too.
For example, I need to know the following:
1. How many shortcuts are in an MSI's shortcut table?
2. What are the long filenames for these shortcuts? ("Name" column value --minus the "SHORTC~1|" part)
3. Where are they being delivered? (what "Directory_" column value resolves to)
Perhaps there is no simple canned vbscript solution for this --I've searched and have yet to find one. Any donated code, or ideas/leads for further research would be greatly appreciated, thanks.
0 Comments
[ + ] Show comments
Answers (8)
Please log in to answer
Posted by:
kkaminsk
18 years ago
Well I wanted to find some more info because I am pretty sure you can achieve what you need for the most part by talking transact SQL to the MSI via VBScript and then I Googled up this nugget.
http://www.installshield.com/news/newsletter/0302-articles/msiaccess.asp
I don't think you'll easily find code that does exactly what you are looking for but I believe that you can code it with VBS if you have the time to sort it out. Then again maybe there is somebody on this board that has written something that you can use off the shelf.
http://www.installshield.com/news/newsletter/0302-articles/msiaccess.asp
I don't think you'll easily find code that does exactly what you are looking for but I believe that you can code it with VBS if you have the time to sort it out. Then again maybe there is somebody on this board that has written something that you can use off the shelf.
Posted by:
norexx
18 years ago
Posted by:
norexx
17 years ago
Posted by:
AngelD
17 years ago
Run this VBScript in a DOS prompt, ex. cscript C:\msiGetShortcutInfo.vbs C:\Package.msi
Dim MsiPath : MsiPath = WScript.Arguments(0)
Dim Session : Set Session = GetSession(MsiPath)
Dim Database : Set Database = OpenDatabase(MsiPath)
Dim TableView : Set TableView = GetTableView(Database, "SELECT * FROM `Shortcut`")
Dim Record : Set Record = TableView.Fetch()
Dim oShortcutInfo : Set oShortcutInfo = CreateObject("Scripting.Dictionary")
Dim sShortcutName
Do While Not (Record Is Nothing)
sShortcutName = Record.StringData(3)
If InStr(sShortcutName, "|") Then sShortcutName = Mid(sShortcutName, InStr(sShortcutName, "|")+1)
oShortcutInfo.Add Record.StringData(1), GetFormatRecord("[" & Record.StringData(2) & "]") & sShortcutName
Set Record = TableView.Fetch()
Loop
WScript.Echo "Shortcuts found: " & oShortcutInfo.Count & vbNewLine
If oShortcutInfo.Count > 0 Then
Dim cShortcuts : cShortcuts = oShortcutInfo.Keys
For Each sShortcut in cShortcuts
WScript.Echo oShortcutInfo.Item(sShortcut)
Next
End If
Function OpenDatabase(MsiPath)
Const msiOpenDatabaseModeReadOnly = 0
Set OpenDatabase = Nothing
Dim Installer : Set Installer = CreateObject("WindowsInstaller.Installer")
Set OpenDatabase = Installer.OpenDatabase(MsiPath, msiOpenDatabaseModeReadOnly)
Set Installer = Nothing
End Function
Function GetSession(msiPath)
Const msiOpenDatabaseModeReadOnly = 0
Const msiUILevelProgressOnly = 64
Dim oInstaller, oDatabase, oSession, oView, oRecord
Set oInstaller = CreateObject("WindowsInstaller.Installer")
oInstaller.UILevel = msiUILevelProgressOnly
Set oDatabase = oInstaller.OpenDatabase(msiPath, msiOpenDatabaseModeReadOnly)
Set oSession = oInstaller.OpenPackage(msiPath, msiOpenDatabaseModeReadOnly)
Set oView = oDatabase.OpenView("Select * From `InstallExecuteSequence` Order By `Sequence`")
oView.Execute
Set oRecord = oView.Fetch
Do While Not (oRecord Is Nothing)
oSession.DoAction oRecord.StringData(1)
If oRecord.StringData(1) = "CostFinalize" Then Exit Do
Set oRecord = oView.Fetch
Loop
Set GetSession = oSession
Set oRecord = Nothing
Set oView = Nothing
Set oSession = Nothing
Set oDatabase = Nothing
End Function
Function GetFormatRecord(sRecord)
Dim FormatRecord : Set FormatRecord = Session.Installer.CreateRecord(0)
FormatRecord.StringData(0) = sRecord
GetFormatRecord = Session.FormatRecord(FormatRecord)
Set FormatRecord = Nothing
End Function
Function GetTableView(Database, Query)
On Error Resume Next
Set GetTableView = Nothing
Dim View : Set View = Database.OpenView(Query)
View.Execute()
Set GetTableView = View
Set View = Nothing
End Function
Posted by:
anonymous_9363
17 years ago
Posted by:
AngelD
17 years ago
Posted by:
anonymous_9363
17 years ago
Kim,
I wasn't having a go at you. I used the bottom-most 'Reply' box instead of the 'Reply' link in norexx's post. That of course meant the reply was to you, when it was intended for norexx. Even so, it reads badly and I apologise to all for what looks like a conciliatory tone. I am duly chastened :(
I wasn't having a go at you. I used the bottom-most 'Reply' box instead of the 'Reply' link in norexx's post. That of course meant the reply was to you, when it was intended for norexx. Even so, it reads badly and I apologise to all for what looks like a conciliatory tone. I am duly chastened :(
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.