I have an MSI file built from my C# Visual Studio 2010. The version is set through the Version
property. I wanted to know if there is a way to determine the version without having to install the file. Currently when right click and view the properties it isn't displayed.
When you right-click an MSI file and then click properties, certain information is displayed on the summary tab. I would like to display the version number from the "product properties" in InstallShield.
"You can extract your MSI package to a local folder and then run . Net Reflector to decompile binaries you are interested at. Only managed code can be decompiled. If someone ran an obfuscator (such as Dotfuscator) on the code, though, all bets are off.
You can tell if an installation is an . msi by the following ways. Go to www.appdeploy.com and select packages on the left side, you can find the package listed and, when selected, it will let you know if the file is an .exe or . msi.
The following code may be helpful. But remember that you should first add a COM reference to the Microsoft Windows Installer Object Library and add the WindowsInstaller namespace to your code. The following function may be what you need.
public static string GetMsiInfo( string msiPath, string Info)
{
string retVal = string.Empty;
Type classType = Type.GetTypeFromProgID( “WindowsInstaller.Installer” );
Object installerObj = Activator.CreateInstance( classType );
Installer installer = installerObj as Installer;
// Open msi file
Database db = installer.OpenDatabase( msiPath, 0 );
// Fetch the property
string sql = String.Format(“SELECT Value FROM Property WHERE Property=’{0}’”, Info);
View view = db.OpenView( sql );
view.Execute( null );
// Read in the record
Record rec = view.Fetch();
if ( rec != null )
retVal = rec.get_StringData( 1 );
return retVal;
}
If you need the version, pass in the name of the MSI file you want, e.g.
string version = GetMsiInfo( "d:\product.msi", “ProductVersion” );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With