static void ShowAllProperties(WindowsInstaller.View msview) { WindowsInstaller.Record record = null; msview.Execute(record); record = msview.Fetch(); while (record != null) { Console.Write(string.Format("\n{0}\t{1}", record.get_StringData(1), record.get_StringData(2))); record = msview.Fetch(); } }
static string GetInstallerString(WindowsInstaller.View msview) { WindowsInstaller.Record record = null; msview.Execute(record); record = msview.Fetch(); return(record.get_StringData(1).ToString()); }
private string returnMsiInfo(string SQL) { Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer"); WindowsInstaller.Installer Installer = (WindowsInstaller.Installer)Activator.CreateInstance(type); Activator.CreateInstance(type); WindowsInstaller.Database db = Installer.OpenDatabase(@"\\iomega-nas\Public1\IT Department\Pinnacle\Deploy\PinnacleSetup.msi", 0); WindowsInstaller.View dv = db.OpenView(SQL); WindowsInstaller.Record record = null; dv.Execute(record); record = dv.Fetch(); return(record.get_StringData(1).ToString()); }
private static void validateInstallerDetails(string msi, out string installRoot, out string prodName) { Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer"); WindowsInstaller.Installer installer = (WindowsInstaller.Installer)Activator.CreateInstance(type); WindowsInstaller.Database db = installer.OpenDatabase(msi, 0); WindowsInstaller.View dv_pp = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property`='MYAPPPATH'"); WindowsInstaller.View dv_pn = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property`='ProductName'"); WindowsInstaller.Record record_pp = null; WindowsInstaller.Record record_pn = null; dv_pp.Execute(record_pp); record_pp = dv_pp.Fetch(); //product path Eg : E:\Web dv_pn.Execute(record_pn); record_pn = dv_pn.Fetch(); //product name installRoot = record_pp.get_StringData(1).ToString(); prodName = record_pn.get_StringData(1).ToString(); Console.WriteLine(); if (string.IsNullOrEmpty(installRoot)) { Console.ForegroundColor = Bad; Console.WriteLine("ERROR : The property 'MYAPPPATH' has not been set. The install path could not be resolved."); Console.ForegroundColor = OriginalForeground; Environment.Exit(0); } if (string.IsNullOrEmpty(prodName)) { Console.ForegroundColor = Bad; Console.WriteLine("ERROR : The property 'ProductName' has not been set. The install path could not be resolved."); Console.ForegroundColor = OriginalForeground; Environment.Exit(0); } Console.ForegroundColor = Info; System.Console.WriteLine("MSI Install path: " + Path.Combine(installRoot, prodName)); Console.WriteLine(); Console.ForegroundColor = OriginalForeground; validateDirectory(installRoot, true, false); }
/// <summary> /// Gets the MSI file version that is to be installed from the msi, before installing it. /// source: https://www.codeproject.com/Articles/31021/Getting-version-from-MSI-without-installing-it /// </summary> /// <param name="msi"></param> /// <returns></returns> public static string GetMsiVersion(string msi) { Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer"); WindowsInstaller.Installer installer = (WindowsInstaller.Installer) Activator.CreateInstance(type); WindowsInstaller.Database db = installer.OpenDatabase(msi, 0); WindowsInstaller.View dv = db.OpenView( "SELECT `Value` FROM `Property` WHERE `Property`='ProductVersion'"); WindowsInstaller.Record record = null; dv.Execute(record); record = dv.Fetch(); return(record.get_StringData(1).ToString()); }