我正在尝试使用从外部调用的 VBScript 从 MSI 表中查找文件的安装位置。
我无法找到使用该 vbscript 从 MSI 表中解析文件位置完整路径的方法。
我已经在 VBscript 中尝试并测试了“ComponentPath”。如果该文件在组件中设置为 keypath 并且安装了包含该组件的 MSI,这将解析为文件的完整路径。
但是,如果将相同组件的注册表设置为密钥路径,则无法显示文件的路径。在这种情况下,路径被解析为注册表配置单元而不是文件位置(例如:注册表配置单元设置为 USERPROFILE 组件而不是文件的键路径,输出 shon 是注册表,因为它设置为键路径)。
在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