VBScript从MSI数据库解析正在安装的文件的完整路径

时间:2013-07-02 10:33:53

标签: vbscript installer windows-installer

我正在尝试使用从外部调用的VBScript来查找MSI表中文件的安装位置。

我无法找到使用该vbscript从MSI表中解析文件位置的完整路径的方法。

我在VBscript中尝试并测试了“ComponentPath”。如果该文件在组件中设置为keypath并且安装了包含该组件的MSI,则将解析为文件的完整路径。

但是,如果将同一组件的注册表设置为键路径,则无法显示该文件的路径。在这种情况下,路径被解析为注册表配置单元而不是文件位置(例如:注册表配置单元被设置为USERPROFILE组件的文件的密钥路径,输出shon是注册表,因为它被设置为keypath)。

是否有一个函数或类在VBScript中实现相同的功能。我可能看起来不正确,或者在放置查询之前我似乎已经耗尽了所有可用的选项。

这是代码的这个特定部分。需要一个包含HKCU注册表和APPDATA文件的空白MSI。

    Set View_Component = Database.OpenView("SELECT * from `Component`")
    View_Component.Execute  
    Set rec_Component   = View_Component.Fetch

        Set View_Registry = Database.OpenView("SELECT * from `Registry`")
    Do While (rec_Component Is Nothing) = False
        ComponentGUID=rec_Component.StringData(2)
        ComponentPath = objInstaller.ComponentPath(FnMSIFetch("ProductCode"),ComponentGUID)
        If (InStr(1, LCase(ComponentPath),"\appdata\")<>0 Or InStr(1, LCase(ComponentPath),"\application data\")<>0) Then
            'MsgBox("Appdata File Possibly Found in "& rec_Component.StringData(1) & " Component)
            Flag_AppdataFileIsFound = True
            View_Registry.Execute
            Set rec_Registry = View_Registry.Fetch
            '*The below line checks if the REGISTRY table is empty or not.
            Do While (rec_Registry Is Nothing) = False
                '*The below line checks if the same component has an entry in registry table, and if that registry is an HKCU one.
                If rec_Component.StringData(1) = rec_Registry.StringData(6) And rec_Registry.StringData(2) = "1" Then
                'MsgBox("HKCU also present in APPDATA Component")
                    Flag_AppDataCompHasRegistryKey = True
                    If rec_Component.StringData(6) = rec_Registry.StringData(1) Then
                        'MsgBox("HKCU is set as keypath for APPDATA Component")
                        Flag_HKCUIsKeyPathForAppdataFile = True
                        Exit Do
                    Else
                        Flag_HKCUIsNotKeyPathForAppdataFile = True
                    End If
                Else
                    Flag_AppDataCompDoesNotHaveRegistryKey = True
                    'MsgBox("HKCU is not present in APPDATA Component - " & rec_Component.StringData(1))

                End If
                Set rec_Registry = View_Registry.Fetch
            Loop
        Else
        Flag_AppdataFileIsNotFound = True
        End If
        Set rec_Component   = View_Component.Fetch
    Loop

0 个答案:

没有答案
相关问题