I have an application that requires at least Windows XP SP3. How can I go about checking for it either in the application itself, or in the MSI, and automating the installation?
A:
I am not sure how to do this before installing, but I know that in the application code itself you can do this...
OperatingSystem os = Environment.OSVersion;
Console.WriteLine("Platform: " + os.Platform);
Console.WriteLine("Version: " + os.Version);
Console.WriteLine("Service Pack: " + os.ServicePack);
Josh Stodola
2010-09-29 21:43:56
A:
Version winXpSp3 = new Version("5.1.2600.5512"); // to be checked, I don't have XP SP3 available...
if (Environment.OSVersion.Version < winXpSp3)
{
MessageBox.Show("You need Windows XP SP3 or later");
...
}
You can use that code in a custom installer step (apparently not, according to Christopher Painter... I leave the code anyway, it could still help someone in another context)
Thomas Levesque
2010-09-29 21:45:42
That is not how Windows Installer works.
Christopher Painter
2010-09-29 21:51:22
Well, in Visual Studio you can create an installer with custom steps written in C#... I don't know exactly how that would work, but it's certainly possible to do it that way, and the OP mentioned .NET in the tags, so he's clearly looking for a .NET solution. Anyway, I don't think this answer deserves a downvote...
Thomas Levesque
2010-09-29 22:00:42
Just because something can be done doesn't mean that it should. Read: http://robmensching.com/blog/posts/2007/4/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres and http://robmensching.com/blog/posts/2007/8/17/Zataoca-Custom-actions-are-generally-an-admission-of-failure
Christopher Painter
2010-09-29 23:11:40
Think of some junior developer coming in and doing some crazy out of process, reinvent the wheel, role your own garbage that could have been 1 line of code in C# and you'll start to understand why I downvoted your answer.
Christopher Painter
2010-09-29 23:12:45
I didn't read everything, but since I never tried it myself and I don't have much experience with installers, I'll assume you're right...
Thomas Levesque
2010-09-29 23:39:31
+4
A:
In MSI you author a LaunchCondition using the Operating System Properties
You want to check that VersionNT > 501 or ( VersionNT = 501 and ServicePackLevel > 2 )
(tweak to meet your exact needs )
In Windows Installer XML this looks like:
<Product...>
<Condition Message="[ProductName] Setup requires Windows XP SP3 or greater to install">VersionNT > 501 or ( VersionNT = 501 and ServicePackLevel > 2 ) or Installed</Condition>
...
</Product>
Christopher Painter
2010-09-29 21:54:17