VBScript to add New Feature in MSI Table
Hi All,
Need you help, i am creating a vbs script to add 1 new Feature if it does not exist in the MSI using the below script.
when i execute the script it fila to create feature, Please help.
Many Thanks
Patil
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const Audit = "Audit"
Const INSTALLDIR = "INSTALLDIR"
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyDelete = 6
Const msiViewModifyReplace = 4
Dim oInstaller : Set oInstaller = CreateObject("WindowsInstaller.Installer")
Dim oDatabase : Set oDatabase = oInstaller.OpenDatabase(WScript.Arguments(0),msiOpenDatabaseModeTransact)
If oDatabase.TablePersistent("Feature") = 1 Then
'create a view of the registry we want to see
Dim sql : sql = "SELECT `Feature` FROM `Feature`"
Dim regView : Set regView = oDatabase.OpenView(sql)
'execute the query
regView.Execute
'fetch the first row of data (if there is one!)
Dim regRecord : Set regRecord = regView.Fetch
'whilst we've returned a row and therefore regRecord is not Nothing
While Not regRecord Is Nothing
If regRecord.StringData(1) <> "Audit" Then
Dim test : test = "INSERT INTO Feature (`Feature`,`Title`,`Description`,`Display`,`Level`,`Directory_`,`Attributes`) VALUES ('Audit','Audit','Audit',3,1,'INSTALLDIR',0)"
Dim tempView : Set tempView = oDatabase.OpenView(test)
tempView.Execute
End If
Set regRecord = regView.Fetch
Wend
End If
oDatabase.Commit
regView.Close
Set regView = Nothing
Set regRecord = Nothing
Set oDatabase = Nothing
Set oInstaller = Nothing
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
anonymous_9363
8 years ago
Posted by:
EdT
8 years ago
Have you downloaded the MSI SDK ? There are MANY example vbscripts in it which can be used as a basis for what you are trying to do, including a couple of VBScripts which you could use from a batch file to edit your MSI tables.
Post a bit more information on what you are trying to achieve and maybe some more relevant answers can be provided.
Are you trying to edit your MSI tables during installation? I've found that a handy solution to some issues.