Use Orca to edit msi from command line?
Asked Answered
C

5

21

I'm using Visual Studio 2008 and have created a setup project for my application. The application has a high-resolution icon (for Vista). There's a bug in Visual Studio, and the installer creates a desktop shortcut with a low resolution icon.

I logged this bug in Microsoft Connect (https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=338258) and finally got an answer, which is to use Orca to edit the msi file and replace the icon. That solutions works fine.

Now I want to automate that process, so I can include it in my build script. Is there a way to do that?

Caliper answered 20/5, 2009 at 8:35 Comment(0)
B
13

You can write VBS, JS (using cscript, which is built in with every Windows) to modify the MSI, the syntax is pretty much SQL like. Here is a MSDN page that shows various examples.

Behm answered 20/5, 2009 at 8:54 Comment(1)
for the VBScript that will execute these queries, try a google search for "WiRunSQL.vbs source"Bryson
N
43

Possibly the easiest solution that I found for this was to create a new "Transform" inside of Orca, and then to apply the transform as a part of my post-build steps.

1) Open the MSI file using ORCA for editing. 2) Click on "New transform" 3) Make all of the applicable changes to your MSI tables using the Orca editor. 4) Click on "Generate transform", and save the file. 5) Edit your build events to execute msitran during the post-build step. like this...

msitran -a (path to transform file) (path to MSI file)

More information about MSITran.exe can be found at the following location... MSITran

This will automatically apply your edits to the MSI file once your installer build has completed, eliminating the need for custom VBScript.

Nickolas answered 17/6, 2010 at 17:3 Comment(6)
That worked great! Much cleaner than a VBScript based solution.Devisee
I want to assign value ARPCOMMENTS into ProductVersion Property. Is that possible through transform fileUlema
One doubt: By applying the transform created by Orca previously to the present product version, we would be loosing the primary output built for the latest version right?Amiraamis
It generates .mst binary file... which is not easily editable if I want to change string on the fly and update installer frequentlyTramel
can't seem to locate this exe in my system plus command line throws an error of not recognized as internal or external command. I installed the windows software development kit in which I selected msi tools now where will this msitran be ?Cahier
@NagarajTantri I tried and to my surprise the transform file will only input/edit things that you edited inside the new transform window time, anything else will not be affected by it whether it be product number version number etc.Cahier
B
13

You can write VBS, JS (using cscript, which is built in with every Windows) to modify the MSI, the syntax is pretty much SQL like. Here is a MSDN page that shows various examples.

Behm answered 20/5, 2009 at 8:54 Comment(1)
for the VBScript that will execute these queries, try a google search for "WiRunSQL.vbs source"Bryson
C
7

I just had to do this too - here is my VBScript file (in case it's useful to anyone)...

Dim msiInstaller
Dim msiDatabase
Dim msiView
Dim msiRecord

Dim pathToMsiFile
Dim pathToIconFile

If WScript.Arguments.Count <> 2 Then
    WScript.Echo "Usage:" & vbCrLf & "  " & WScript.ScriptName & " <path-to-msi> <path-to-icon>"
    WScript.Quit
End If

Dim pathToMsi, pathToIcon
pathToMsi = WScript.Arguments(0)
pathToIcon = WScript.Arguments(1)

Set msiInstaller = CreateObject("WindowsInstaller.Installer")

Set msiRecord = msiInstaller.CreateRecord(1)
msiRecord.SetStream 1, pathToIcon

Set msiDatabase = msiInstaller.OpenDatabase(pathToMsi, 1)
Set msiView = msiDatabase.OpenView("UPDATE Icon SET Data = ? WHERE Name <> ''")
msiView.Execute msiRecord

msiDatabase.Commit

This script replaces all shortcut icons in the MSI database with a single icon - if you need to be selective then you have some more work to do.

Charlottetown answered 14/5, 2010 at 10:53 Comment(0)
G
2

You can use perl script to modify the installer msi package. You can use Win32 OLE for this. Open the MSI using Win32::OLE->new API. Open the MSI database and execute the SQL queries to do the update.

This perl script can be used in builds.

This link might help you to write the required one.

Grandaunt answered 20/5, 2009 at 8:47 Comment(0)
C
2

Since you're used to work with Orca, just save the modifications as a transform file using Orca and then applying it with 'msitran' in the post build event of your setup project.
I'm using this in a setup project and it works just great.

Coin answered 28/4, 2010 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.