Link to home
Start Free TrialLog in
Avatar of Matt_Jsy
Matt_Jsy

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of SameerJagdale
SameerJagdale
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vadim Rapp
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.
Avatar of Matt_Jsy
Matt_Jsy

ASKER

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
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.
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.
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
ok, thanks for all the comments. I thnk I have found a solution with help from the first post and a bit more investigation.