How to automate editing an Msi-file using a simple script
Note : This is a tech post, prolly not really interesting to most SoccerProject-readers who follow this blog. My apologies to them.
Today I found something which I’ve been wanting to find out for a long time and which will save me a lot of time in the future. For the past few years I managed a C# Visual Studio application and its Setup Project. During installation the user needs to fill in a password and unfortunately it’s not possible in VS to define the textbox as Password-Masked.
Therefor I manually used Orca, which is a nice tool for this, but it took me 5 extra minutes for each new installation version I had to make, which happened quite often. Not to mention the times I forgot to execute this Post Build Step manually. You can find a very good article on how to do this on The CodeProject.
So I started looking once again today for a way to automate this and hey, I was finally lucky at EggHeadCafe. Within five minutes I had myself a little VB-script, added it as a PostBuildStep to my Installer Project and now I never have to think about it ever again. Everything will be handled automatically🙂
Below you can find the script-code which is completely copied from the link above. This posting is provided “AS IS” with no warranties, and confers no rights. I hope it will be useful for some of you in the future…
Development comment below, or link to this permanent URL from your own site.
Const msiOpenDatabaseModeTransact = 1
' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim openMode : openMode = msiOpenDatabaseModeTransact
Dim database : Set database = installer.OpenDatabase("MySetup.msi", openMode)
Dim view : Set view = database.OpenView("UPDATE Control SET Control.Attributes = '2097159' WHERE Control.Dialog_ = 'CustomTextA' AND Control.Control = 'Edit1'")
Set view = Nothing
Set database = Nothing