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,354 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

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