locked
Need help in writing a vbscript RRS feed

  • Question

  • Hi,

    I need help in wring a vbscript. I have serached for the vbscript on the net, but could not find any.

    I need to add a file to an msi using vbscript. - That's the requirement.

    For this I have done the following with the help of vbscript.

    1. With the insert statement I inserted a new copmonent in the FeatureComponent Table.

    2. Now the next thing I did is, I inserted a new row in the File table using insert statement again. The file is uncompressed.

    3. Since the file is a non-version file I also added a row in the MSIFileHash table.

    4. Also, now added the Component in the component table.

    After doing this I am able to see the chnages in the mst, however whrn I try to install it I get an error 2725 (Invalid database tables).

    Can somebody please post a vbscript which can add a file to an msi?

     

    Wednesday, November 26, 2014 9:37 AM

Answers

  • If I understand your question, you can't simply add a file to an MSI table the way you are trying to do it. This would require a great deal of technical expertise about how Windows Installer database (MSI) files work. Your question is well outside the scope of this forum (this is a general Windows scripting forum, not a Windows Installer forum).

    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Bill_Stewart Thursday, December 11, 2014 6:30 PM
    • Marked as answer by Bill_Stewart Monday, December 29, 2014 9:51 PM
    Wednesday, November 26, 2014 5:40 PM

All replies

  • I forgot to mention, I have also made changes to the Media table.
    Wednesday, November 26, 2014 9:43 AM
  • If I understand your question, you can't simply add a file to an MSI table the way you are trying to do it. This would require a great deal of technical expertise about how Windows Installer database (MSI) files work. Your question is well outside the scope of this forum (this is a general Windows scripting forum, not a Windows Installer forum).

    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Bill_Stewart Thursday, December 11, 2014 6:30 PM
    • Marked as answer by Bill_Stewart Monday, December 29, 2014 9:51 PM
    Wednesday, November 26, 2014 5:40 PM
  • In the MSI SDK there is a tool called ORCS that edits MSI files.  I recommend using that to test you assumptions about how to add a file. It is more complex than you think.

    https://support.microsoft.com/KB/255905?wa=wsignin1.0


    ¯\_(ツ)_/¯

    Wednesday, November 26, 2014 6:09 PM
  • http://msdn.microsoft.com/en-us/library/aa370557(v=vs.85).aspx

    Orca can edit and merge MSI files.


    ¯\_(ツ)_/¯

    Wednesday, November 26, 2014 6:10 PM
  • Hi All,

    Thanks for all your responses.

    Yes, It is not so easy. I never said it was.  Thanks for pointing out Orca. We use Orca on a daily basis.

    What exactly I am looking at, is this.

    We have some standard applications which needs to be repackaged every month. The repackaging process is same and does not change at least for these packages. So I was actually looking at automating these things.

    What I did so far.

    First we have created an object for Windows installer. I have then taken a copy of the original msi and then opened the database of this temporary msi database in transact mode. Once the database is opened we can use select, insert, update and delete statements to update the database.  

    I could successfully add a registry to the msi. The component was also added successfully to the component table. I also could make changes to the Property table.

    The tricky part comes with the addition of file to the file table.

    The addition of file requires the following steps.

    1. Add a new row to the file table. This can be done with the Insert statement.

    2. We then need to associate the file to a new component or any other component already existing in the msi. In my case I am creating a new component.

    3. We then have to associate this components to a feature in the FeatureComponents table.

    4. Since the file I am adding is a non-versioned file, a new row also has to be added to the MSIFILEHASH table.

    I could see the changes that I have done using the mst. But when I try to install the msi with the mst, I get the error 2725. I checked everything. All the other steps except for the file addition works fine.

    To check whether I am indeed right, I have did this.

    Skipped the file addition part to the msi. Every other change that I make works and I am able to install the msi with the mst successfully.

    For obvious security reasons I will not be able to share the vbscript with you. If you guys think, that this is not a right forum for this question, please let me know the right forum. I have been stuck with this issue from the past 6 months. Any help would really be appreciated.

    Thursday, November 27, 2014 3:04 AM
  • Again - thiis what Orca is for.  THe other method is Visual Studio which has extensions that will rebuild an MSI when the files change.

    THere is not script method to do what you want.   YOu must use some tool to regenerate the MSI.  Jusst adding files will not necessarily create the effect you want.

    Spend some time with the SDK reviewing how MSI's are built and maintianed. 

    I am almost completely certain that no one here has a script that will do what you want.


    ¯\_(ツ)_/¯

    Thursday, November 27, 2014 3:10 AM
  • Here are numerous examples of how to do this.

    https://www.google.com/?gws_rd=ssl#newwindow=1&q=orca+add+file+to+msi


    ¯\_(ツ)_/¯

    Thursday, November 27, 2014 3:13 AM
  • Here are instructions on how to rebuild an MSI using VBScript: http://www.codeproject.com/Articles/383481/Editing-an-MSI-Database

    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, November 27, 2014 3:19 AM
    Thursday, November 27, 2014 3:19 AM
  • Hi jrv,

    Thanks for your reply. It's strange that when a script can make changes to the property table, registry table and Component table, Why can't a file table. Probably, I am missing some vital piece of information. Let me try it again.


    Thursday, November 27, 2014 3:55 AM
  • This is a scripting forum, not a Windows Installer "how to" forum.

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 27, 2014 6:16 PM
  • Hi,

    I was able to get the solution for this issue.

    As mentioned, I was trying to add a non-versioned file to the msi. The solution was to add a dummy version I the version column of the File table. There is  no need to add an entry for the file to the MsiFileHash Table. I was able to finally insert the file into the msi without any issues.

    1. Add a component to the component table.

    2. Associate this component to any feature in the FeatureComponents table.

    3. Add the File to the File table. Even if it's a non-versioned file just add a dummy version in the version column of the File table.

    4. Update the Media table.

    Thursday, September 24, 2015 8:48 AM
  • Glad you found a solution, but as noted, this is a question regarding details about Windows Installer, not scripting.

    -- Bill Stewart [Bill_Stewart]

    Thursday, September 24, 2015 12:31 PM