views:

317

answers:

1

I need to install a USB driver for a device so that it is recognised by ActiveSync (under XP) or Mobile Device Center (under Vista).

However the .INF file which needs to be installed for ActiveSync (XP) is different from the .INF file for MDC (Vista). So I need an installer which can determine if the target is XP or Vista and install the correct file.

I am just using Visual Studio 2005 to create the installer, rather than anything more complicated, but I can't see any way to make installation of a file dependent on the target OS. Do I need to create a Custom Action to do this? If so what should it do, e.g. set an environment variable?

+4  A: 

Use Windows Installer Properties:

Operating System Property Values

Especially:

VersionNT

WindowsBuild

ServicePackLevel

Example:

VersionNT>500 And VersionNT<600 would mean XP

VersionNT=600 would mean Vista

William Leara
"VersionNT>500 And VersionNT<600 would mean XP" what about server 2003?"VersionNT=600 would mean Vista" This is not a good idea, you probably want >=
Anders
Right, I was trying to give a general example. If you follow the link I posted to the OS Property Values, you'll see all the details. 502 is both Server 2003 and XP 64-bit. So things change if you want to consider XP 64-bit too -- you'd use the VersionNT64 property additionally. Again, see the MSDN article I linked too and make up a condition to suit your needs.
William Leara
Thanks William -- that works fine. I don't need to worry about Server versions or 64-bit versions in my case so "VersionNT>=500 And VersionNT < 600" for XP files and "VersionNT>=600" for Vista does the trick just fine.
AAT
You can distinguish between 32 and 64 bit architectures using the VersionNT and VersionNT64 properties; VersionNT will be set for 32-bit, VersionNT64 for 64-bit. With the most current operating systems (i.e. Vista and Server 2008, Windows 7 and Server 2008 R2) you can't even use VersionNT, WindowsBuild, and ServicePackLevel to distinguish the workstation and server OS since they're the same. For that you need to use the `MsiNTProductType` property.
CodeSavvyGeek