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,347 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Class object 2 26
Runtime Exceptions when trying to submit data 28 37
Angular JS Route 3 50
What do you call this line of code in this .NET Core page? 4 26
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

25 Experts available now in Live!

Get 1:1 Help Now