/build/static/layout/Breadcrumb_cap_w.png

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:
Posted by: Maidens 7 years ago
Third Degree Blue Belt
0

Why not use Installshield or Orca?

If its a vendor MSI make sure and generate an MST to incoroprate your property field changes.

Posted by: lanselots 7 years ago
Fifth Degree Brown Belt
0
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
Third Degree Blue Belt
0
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
Black Belt
0
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
Fifth Degree Brown Belt
0

Hi,

Thanks for giving me all those posts but I already went through all of them and that did not helped me and that is why I posted my question here by thinking maybe someone has created such script and using it to add MSI property by running script.

Posted by: captain_planet 7 years ago
Black Belt
0

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
Fifth Degree Brown Belt
0

Thank you for creating it and it is working. Only thing for me challenging now is to add for example few more properties. Tried and nothing worked :(

Posted by: lanselots 7 years ago
Fifth Degree Brown Belt
0
I think I messed up by asking VBScript for creating one property as I would prefer for like couple of them but when I try to edit one provided above nothing works. Hope someone could help me with that as well
Posted by: lanselots 7 years ago
Fifth Degree Brown Belt
0

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
Red Belt
0
Why on God's green Earth are you manipulating an MSI directly - and incredibly painfully at that!! - when you can add properties and their values via a transform, especially as you say you "know all about Orca"?
Posted by: lanselots 7 years ago
Fifth Degree Brown Belt
0
After creating repackaged .irp you create .ism and then you edit it as you wish where in the end you get MSI but how would make your life easier if you could drug your ism on script and it would add required standards so after what you build your MSI and no manual input. Would that be helpful?
Posted by: lanselots 7 years ago
Fifth Degree Brown Belt
0
Never mind, created my self :) Thanks all for the assistance.
Posted by: captain_planet 7 years ago
Black Belt
0
If that's what you need it for you'd be better off using Installshield Editor Templates.
Posted by: anonymous_9363 7 years ago
Red Belt
0
>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.

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
Red Belt
0
> 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.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ