Skip to content

Instantly share code, notes, and snippets.

@williamjacksn
Last active August 29, 2015 14:17
Show Gist options
  • Save williamjacksn/4e8d90878b9695c5531a to your computer and use it in GitHub Desktop.
Save williamjacksn/4e8d90878b9695c5531a to your computer and use it in GitHub Desktop.
Find possible public properties used in an MSI file

Example:

C:\Users\Publib\Documents>cscript.exe //nologo find_public_properties.vbs "IBM SPSS Statistics 20.msi"
** Searching for possible public properties in IBM SPSS Statistics 20.msi

ISSCHEDULEREBOOT
HELPCHOICE
LICENSETYPE
PATCH
REINSTALL
SHOWLAUNCHPROGRAM
PROGRAMFILETOLAUNCHATEND
LICVALVER
RESUME
MINIMAL_INSTALL_TEXT_ON
STUDENTWARE
DEMOWARE
LSHOST
IS_SQLSERVER_AUTHENTICATION
LAUNCHPROGRAM
REINSTALLMODE
SERIALNUMVALRETRYLIMIT
SERIALNUMVALRETURN
SERIALNUMVALSUCCESSRETVAL
IS_SQLSERVER_STATUS
ACTION
CCP_TEST
ISSETUPDRIVEN
CCP_SUCCESS
AUTHCODE
REMOVE
IS_MAJOR_UPGRADE
INSTALLDIR
SPSS14INSTALLDIR
SPSS15INSTALLDIR
STATISTICSLOCKED
set unique_tokens = CreateObject("Scripting.Dictionary")
Set wi = CreateObject("WindowsInstaller.Installer")
msi_file = WScript.Arguments(0)
WScript.Echo "** Searching for possible public properties in " & msi_file
WScript.Echo ""
Const open_database_mode_read_only = 0
Set db = wi.OpenDatabase(msi_file, open_database_mode_read_only)
find_public_properties("select Condition from AdminExecuteSequence")
find_public_properties("select Condition from AdminUISequence")
find_public_properties("select Condition from AdvtExecuteSequence")
find_public_properties("select Condition from Condition")
find_public_properties("select Condition from ControlCondition")
find_public_properties("select Condition from ControlEvent")
find_public_properties("select Condition from InstallExecuteSequence")
find_public_properties("select Condition from InstallUISequence")
find_public_properties("select Condition from LaunchCondition")
For Each key In unique_tokens.Keys
WScript.Echo key
Next
Sub find_public_properties(sql)
Set v = db.OpenView(sql)
v.Execute
Do
Set rec = v.Fetch
If rec Is Nothing Then
Exit Do
End If
data = rec.StringData(1)
data = Replace(data, "(", " ")
data = Replace(data, ")", " ")
data = Replace(data, "=", " ")
data = Replace(data, "<", " ")
data = Replace(data, ">", " ")
tokens = Split(data)
For Each token In tokens
If is_public_property(token) Then
If Not unique_tokens.Exists(token) Then
unique_tokens.Add token, ""
End If
End If
Next
Loop
End Sub
Function is_public_property(p)
If Len(p) = 0 Then
is_public_property = False
Exit Function
End If
For i = 1 To Len(p)
char = Mid(p, i, 1)
If Not is_valid_char(char) Then
is_public_property = False
Exit Function
End If
Next
first_char = Asc(p)
If first_char = 46 Or (first_char > 47 And first_char < 58) Then
is_public_property = False
Exit Function
End If
If p = "AND" Or p = "NOT" Or p = "OR" Then
is_public_property = False
Exit Function
End If
is_public_property = True
End Function
Function is_valid_char(c)
a = Asc(c)
If a = 46 Or a = 95 Or (a > 47 And a < 58) Or (a > 64 And a < 91) Then
is_valid_char = True
Else
is_valid_char = False
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment