列出 msi 文件中的表? [英] List Tables in an msi file?

查看:19
本文介绍了列出 msi 文件中的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用

示例:脚本程序:

  • 1) 另存为 ListMSITables.vbs 在桌面上(链接到 github.com)
  • 2) 将 MSI 文件拖放到 VBScript 上
  • 3) 一个消息框将显示表的数量和表名

注意:非常大的 MSI 文件可能会使消息框溢出屏幕.只需按任意键即可关闭(我使用 ESC).

出错时继续下一步常量 msiOpenDatabaseModeReadOnly = 0Dim 安装程序:设置安装程序 = 无Set installer = Wscript.CreateObject("WindowsInstaller.Installer")变暗计数器:计数器 = 0' 验证传入的拖放参数If WScript.Arguments.Count = 0 Then MsgBox "将 MSI 文件拖放到 VBScript" End If文件名 = Wscript.Arguments(0)If (Right (LCase(filename),3) <> "msi") ThenWScript.退出万一Dim 数据库:设置数据库 = installer.OpenDatabase(filename, msiOpenDatabaseModeReadOnly)昏暗的表、视图、记录Set view = database.OpenView("SELECT `Name` FROM _Tables")查看.执行做设置记录 = view.Fetch如果记录什么都没有,则退出执行table = record.StringData(1)表格 = 表格 + 表格 + vbNewLine计数器 = 计数器 + 1环形MsgBox "表格数量:" + CStr(counter) + vbNewLine + vbNewLine + 表格设置视图 = 无

<块引用>

Github.com:上面显然是脚本.只需pillage github.com 了解更多相同的,在各种语言中.

How does one use SQL to list the tables in an MSI file?

解决方案

MSI SDK: The _Tables table is a read-only system table that lists all the tables in the database. Query this table to find out if a table exists.

Adapting the script WiExport.vbs from the Windows Installer Scripting Examples from the Windows Installer SDK you get something like the below.


MSI SDK VBScripts: In order to find WiExport.vbs: With Visual Studio installed, look under: %ProgramFiles(x86)%\Windows Kits\10\bin\10.0.17763.0\x86 (adjust version numbers for your current installation) (or just search for it on github.com).


Sample Screen Shot: Here is a sample run of the script below:

Sample: Procedure for script:

  • 1) save as ListMSITables.vbs on desktop (link to github.com)
  • 2) drag-and-drop an MSI file onto the VBScript
  • 3) a message box will show number of tables, and table names

Note: Very large MSI files could make the message box overflow the screen. Just press any key to dismiss (I use ESC).

On Error Resume Next
Const msiOpenDatabaseModeReadOnly = 0

Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim counter : counter = 0

' Verify incoming drag and drop arguments
If WScript.Arguments.Count = 0 Then MsgBox "Drag and drop an MSI file onto the VBScript" End If
filename = Wscript.Arguments(0)
If (Right (LCase(filename),3) <> "msi") Then 
   WScript.Quit
End If

Dim database : Set database = installer.OpenDatabase(filename, msiOpenDatabaseModeReadOnly)
Dim table, view, record

Set view = database.OpenView("SELECT `Name` FROM _Tables")
view.Execute

Do
    Set record = view.Fetch
    If record Is Nothing Then Exit Do
    table = record.StringData(1)
    tables = tables + table + vbNewLine
    counter = counter + 1
Loop

MsgBox "Number of tables: " + CStr(counter) + vbNewLine + vbNewLine + tables

Set view = Nothing

Github.com: The above is obviously VBScript. Just pillage github.com for more of the same, in all kinds of languages.

这篇关于列出 msi 文件中的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆