VBScript to add property
Hi,
Can someone share please VBScript which adds property in to MSI property table.
0 Comments
[ + ] Show comments
Answers (15)
Answer Summary:
Please log in to answer
Posted by:
Maidens
7 years ago
Posted by:
lanselots
7 years ago
Thank you for replaying but idea would be to create script which allows you to add Properties to your MSI by running script outside MSI. Only thing is that I`m not good scripter and don`t know how to do that. I know everything about ORCA, InstallShield or other tools to add properties or modify MSI, only thing what I'm looking is to do that by running VBScript.
Posted by:
Maidens
7 years ago
Lanselots
Well in that case these should help you on your way.........
http://www.itninja.com/question/how-to-use-msi-properties-in-vbscript
http://stackoverflow.com/questions/1609250/how-do-i-add-update-a-property-inside-an-msi-from-the-command-line
You might want to visit these below first to gain a better understanding of Vb scripting.
https://www.tutorialspoint.com/vbscript/vbscript_tutorial.pdf
http://www.cruto.com/resources/vbscript/vbscript-examples/
Good Luck!
Posted by:
captain_planet
7 years ago
I created some VBScript for Windows Installer tutorials here a while back: http://www.alkanesolutions.co.uk/category/windows-installer/tutorials-vbscript-for-windows-installer/
The earlier tutorials should help you out, specifically tutorial 4 for inserting values:
http://www.alkanesolutions.co.uk/2012/12/08/tutorial-4-how-do-i-insert-a-registry-value/
Posted by:
lanselots
7 years ago
Posted by:
captain_planet
7 years ago
Top Answer
The example provided can be easily modified to add to the Property table instead of the Registry table.... Save the following inside a VBS file and drag your MSI on to it (lo and behold I've forgotten where the code tags are nowadays.....hey ho):
'create 2 constants - one for when we want to just query the MSI (read) and one for when we want to make changes (write)
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
'create WindowsInstaller.Installer object
Dim oInstaller : Set oInstaller = CreateObject("WindowsInstaller.Installer")
'open the MSI (the first argument supplied to the vbscript)
Dim oDatabase : Set oDatabase = oInstaller.OpenDatabase(WScript.Arguments(0),msiOpenDatabaseModeTransact)
'check if Property table exists (0 is a temporary table, 1 is a permanent table)
If oDatabase.TablePersistent("Property") = 1 Then
'substitute ? in for each parameter
Dim sql : sql = "INSERT INTO `Property` (`Property`,`Value`) VALUES (?,?)"
Set regRecord = oInstaller.CreateRecord(2)
regRecord.StringData(1) = "PROPERTYNAME"
regRecord.StringData(2) = "PROPERTYVALUE"
'create a view of the query we want to execute
Dim regView : Set regView = oDatabase.OpenView(sql)
'execute the query, and pass in the record object as an argument
regView.Execute(regRecord)
End If
oDatabase.Commit 'save changes
regView.Close
Set regView = Nothing
Set regRecord = Nothing
Set oDatabase = Nothing
Set oInstaller = Nothing
Posted by:
lanselots
7 years ago
Posted by:
lanselots
7 years ago
Posted by:
lanselots
7 years ago
Hi all,
I have worked on this script all weekend, even went through tutorials, but could not figure it out how to add more than one property and thought maybe someone could help me a bit more by adding like several more strings to the script so it would add more than just one Property. Maybe like showing:
Add this line so you will get option to add more properties or something.
Hope to get some feedback from you guys.
Thanks.
Posted by:
anonymous_9363
7 years ago
Posted by:
lanselots
7 years ago
Posted by:
captain_planet
7 years ago
If that's what you need it for you'd be better off using Installshield Editor Templates.
Posted by:
anonymous_9363
7 years ago
>Never mind, created my self
...and, in the true spirit of internet forum use, you're not going to share how you did that with anybody. Nice.
...and, in the true spirit of internet forum use, you're not going to share how you did that with anybody. Nice.
Comments:
-
You know how it is working, if people would try to help each other by simple replying if they know how to do things that would be helpful, because I did asked VBScript which add property and after couple of comments captain_planet added it, not like maybe proper one but still he added. So thanks to him for that, but if people are coming back to you like why don`t you try this and that, do this and that but still that was not my question how to do things differently as I was just asking script and in this nature the script provided by captain_planet is actual answer to my question and that can be used if you just modify it little bit. So don't get this wrong for now, but I will not provide full script which I have if only maybe someone will ask here in blog and I`m now guessing it might be you ;) - lanselots 7 years ago
Posted by:
anonymous_9363
7 years ago
> I will not provide full script which I have if only maybe someone will ask here in blog
Just look how the queue of people willing to help you just got even smaller.
>I`m now guessing it might be you
Errrr....no. I'm more than competent with scripting, thanks. Oh and some of mine are publicly available, too.
Just look how the queue of people willing to help you just got even smaller.
>I`m now guessing it might be you
Errrr....no. I'm more than competent with scripting, thanks. Oh and some of mine are publicly available, too.