Tuesday, February 22, 2011

Whats that HASH?

Want to update a MsiFileHash value? Use this simple VBScript to get the hash values for a file then you can update the table using a transform.

Dim FilePath, oDlg
If WScript.Arguments.Count = 1 Then
FilePath = WScript.Arguments.Item(0)
Else
With CreateObject("UserAccounts.CommonDialog")
.Filter = "All Files|*.*"
If .ShowOpen = 0 Then
Wscript.Quit -1
Else
FilePath = .FileName
End If
End With
End If

With CreateObject("WindowsInstaller.Installer").FileHash(FilePath,0)
InputBox "File Hash for:" & vbCrLf & FilePath, "msiFileHash Value Generator", .StringData(1) & "," & .StringData(2) & "," & .StringData(3) & "," & .StringData(4)
End With
WScript.Quit 0

1 comment:

  1. FYI: here is a more advanced version that will actually update the table directly..(Which is a No no!): http://www.workstationtalk.com/content/how-update-msifilehash-table-msi-database-using-vb-script

    ReplyDelete