Inserting a registry value in an MSI database (Modify method)

Related Posts
4 Comments
shashi patil

Hi,

i have used your above script to add 1 new Feature if it does not exist in the MSI using the below script.

when i execute the script it executes without any error but does not create the feature, Please help.

Many Thanks
shashi

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

Else
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

shashi patil

my bad the else statment is comented

Thanks Patil. Also when you make a post on ITNinja please post a reference link back to my site (it helps me with SEO). Thanks.

shashi patil

sure will do that thanks

Leave a Reply
Send us a message

Send your message any time you want.

Our usual reply time: 2 Business Hours
Send us a message

Have a question? Send us a message.

Our usual reply time: 2 Business Hours