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,361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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