Solved

How do I check the version of an MSI/Setup.exe against what is installed on a machine using C#?

Posted on 2008-10-23
7
1,342 Views
Last Modified: 2013-12-17
Hi.

I have an MSI package that installs various .dlls on a local machine. This MSI/Setup.exe sits on the server. I want to run an exe (built in C#) that opens up and checks the version of the MSI/Setup.exe on the server and makes sure the latest version is installed on the local machine.

For example, the version number of my installer program is 1.0.2, once installed I can see this version number in the registry. However if I check the version of the setup.exe using..

FileVersionInfo v = FileVersionInfo.GetVersionInfo(InstallFile);

I get version 8.0.50727.42!

Any idea how I can see if the setup.exe is newer then the installed version on the local machine?

Thanks a lot.
0
Comment
Question by:Matt_Jsy
  • 3
  • 3
7 Comments
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 500 total points
ID: 22784771
check if this helps:
WindowsInstaller.Installer inst = new Installer();

Activator.CreateInstance(Type.GetTypeFromProgID("WindowsInstaller.Installer"));

Database;

db = inst.OpenDatabase(<your msi filename>, 0);

string;

query = "select * from Property where Property = \'ProductVersion\'";

WindowsInstaller.View;

view = db.OpenView(query);

view.Execute(null);

Record record = view.Fetch();

string version = record.get_StringData(2);

Response.Write(("Version: " + version));

Open in new window

0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22785101
Because setup.exe has nothing to do with your product. It's a standard executable that launches the msi, and its contents and version reflect not anything pertaining to your product but the way it launches the msi. You have no control over it - unlike over the MSI. MSI is where the true version is.
0
 

Author Comment

by:Matt_Jsy
ID: 22787389
OK, thanks for the help. I have managed to get the version number from the MSI package on the network now. Is there any easy way to get the version number of the program already installed on the machine back? I can see it in the registry but there must be a better way than having to look through the registry manually?

Thanks again
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22787752
Take a look at Scriptomatic or WMI Code Creator. The class you want is w32_product. It's not very reliable though, will fail on many machines because of  various WMI errors that would never show up without running this. But maybe your network is cleaner than mine :-)

That said, there are much better ways to achieve what you are trying to do. If your network is active directory-based, all you have to do is publish or assign the packages in group policy, and Windows will find and update them automatically. You can specify that package A is update of package B and many other things.
0
 

Author Comment

by:Matt_Jsy
ID: 22794193
Its to be used when rolling out our product on client sites. Im guessing some of the networks may be rather messy like you say.

hmm, might have to have a rethink if there isn't a clean and reliable way of doing it.

Thanks for the suggestions.
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 22795033
Major msi-authoring vendors such as Wise and Installshield have developed mechanics that install on user machine new service that periodically checks for the updates by calling provider's website where you register your product and updates for a fee. Most developers however incorporate auto-update functionality in the application itself, because the fee is not exactly low, and because this method borders on spyware - here's typical discussion at http://gadgetopia.com/post/3837
0
 

Author Comment

by:Matt_Jsy
ID: 22795297
ok, thanks for all the comments. I thnk I have found a solution with help from the first post and a bit more investigation.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Open a folder with partial name 14 29
Set form below another form 3 26
Getfiles in vb.net 28 22
Close word object 13 21
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now