Last active
August 29, 2015 14:02
-
-
Save yukitos/fb9bcb2a090ee51d8fcb to your computer and use it in GitHub Desktop.
Get ProductCode value from a specific msi file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var msi = new ActiveXObject("WindowsInstaller.Installer"); | |
var msiOpenDatabaseModeReadOnly = 0; | |
var db = msi.OpenDatabase("test.msi", msiOpenDatabaseModeReadOnly); | |
var view = db.OpenView("SELECT * FROM Property WHERE Property = 'ProductCode'"); | |
view.Execute(); | |
for (var r = view.Fetch(); r != null; r = view.Fetch()) { | |
WScript.Echo(r.StringData(1) + "=" + r.StringData(2)); | |
} | |
view.Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Deployment.WindowsInstaller.Linq; | |
using System; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var db = new QDatabase("test.msi")) | |
{ | |
var prop = db | |
.Properties.Where(i => i.Property == "ProductCode") | |
.AsEnumerable() | |
.First(); | |
Console.WriteLine(prop.Value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment