Skip to content

Commit

Permalink
Clean up modify_msi.vbs
Browse files Browse the repository at this point in the history
Also, put blame where it belongs, which is Windows Installer. If this
was a bug in WiX, then the fix would be to enforce 8.3 file names for
ODBC drivers, and we wouldn't like that very much either, would we?
  • Loading branch information
chrullrich committed Oct 12, 2024
1 parent b3ab901 commit 1796fa6
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions installer/modify_msi.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,51 @@
' When the dll name of the driver is not of 8.3-format
' the modification of the FileName is needed
'
' This is to work-around a bug in the WiX Toolset, see
' This is to work-around an oversight in Windows Installer, see
' http://wixtoolset.org/issues/1422/
'
' We remove the short name from the filename field in the File-table
' of the two DLLs that need to be registered as ODBC drivers. Strictly
' speaking, that makes the contents of the table invalid, because a short
' name is mandatory, but Windows Installer seems nevertheless install it
' just fine.
'
option Explicit

Const msiOpenDatabaseModeTransact = 1
Option Explicit

Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const query = "SELECT * FROM File"

Dim msiPath : msiPath = Wscript.Arguments(0)
Dim installer, database
Dim view, record
Dim pos, filename

Dim installer
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim database
Set database = installer.OpenDatabase(msiPath, msiOpenDatabaseModeTransact)

Dim query
query = "Select * FROM File"
Dim view
Set database = installer.OpenDatabase(WScript.Arguments(0), _
msiOpenDatabaseModeTransact)
Set view = database.OpenView(query)
view.Execute
Dim record
Set record = view.Fetch
Dim gFile, pos
Do While not record Is Nothing
' Check if the FileName field is ShortName|LongName
gFile = record.StringData(3)
pos = InStr(gFile, "|psqlodbc")
If (pos > 0) Then
' Omit the ShortName part
gFile = Mid(gFile, pos + 1)
WScript.echo record.StringData(3) & " -> " & gFile
' And update the field
record.StringData(3) = gFile
view.Modify msiViewModifyUpdate, record
End If

Set record = view.Fetch
Do While Not record Is Nothing

filename = record.StringData(3)
pos = InStr(filename, "|psqlodbc")

If (pos > 0) Then

' Remove the ShortName part
filename = Mid(filename, pos + 1)
WScript.echo record.StringData(3) & " -> " & filename

record.StringData(3) = filename
view.Modify msiViewModifyUpdate, record

End If

Set record = view.Fetch

Loop

database.Commit

0 comments on commit 1796fa6

Please sign in to comment.