Page 1 of 1
OS Detection Ambiguity
Posted: Tue Nov 14, 2006 6:28 am
by H4nd0
The OS detections appear ambigious.
For example, in MSI Code:
Get System Settings Windows 2000 into VAR
Returns TRUE on WinXP
So how can I really detect when I am on XP? To my mind OS detection should be far more explicit:
NT 4.0 (NT4)
NT 5.0 (Win2K)
NT 5.1 (WinXP)
NT 5.2 (Win2K3/XP x64)
NT 6.0 (Vista)
Posted: Tue Nov 14, 2006 11:30 am
by MichaelNesmith
That is actually not meant to be ambiguous, but convenient. The intended usage is "at least". So if your application requires "at least" Windows 2000, the check will automatically succeed on XP also, saving you some manual effort in the MSIcode.
Posted: Tue Nov 14, 2006 3:24 pm
by H4nd0
Well you might need specific OS detection ...
I realise the "at least" bit but its tiresome to say:
Am I on Vista? No
Am I on Win2K3? No
Am I on XP? Yes ... Hooray! Install this component
Am I on Win2K3? You idiot!
Am I on NT4? What are you smoking ...
It's easy to grab this via OS Major and Minor ... I can understand service packs + other components being more complex to isolate.

MSI OS properties
Posted: Mon Nov 27, 2006 5:07 pm
by mberterm
Using the API MsiGetProperty with the natively supplied MSI OS properties might also help.
Operating System Property Values
http://msdn.microsoft.com/library/en-us ... values.asp
Posted: Fri Sep 18, 2009 10:53 am
by desjardd
can anyone elaborate on how we can do this? We are using v9.
Thanks!
Posted: Fri Sep 18, 2009 11:55 am
by DevilSun
I took the easy, lengthy, but overly verbose route of using a massive nested if checking highest to lowest. Once the very first condition is met, you know that's the OS they are on.
Example:
Code: Select all
Declare all your variables, "ISWINDOWS7", "ISWIN2008", "ISVISTA", "ISXP", etc.
Get System Setting Windows 7 into ISWINDOWS7
if Variable ISWINDOWS7 Equals FALSE
Get System Setting Windows 2008 into ISWIN2008
if Variable ISWIN2008 Equals FALSE
Get System Setting Windows Vista into ISVISTA
Comment: ... etc for all you need to check, then I use else cases to check SP for that OS
else
Comment: Verify SP level of met condition if needed
end if
end if
Now you have explicit values for what OS, plus potential SP requirement checking. It's lengthy, verbose, and not easy to maintain, but it works just fine.
The other way is to get the exact OS Version, and parse it out into major/minor/build...either way, you'll have a pretty deep set of if's/else's and what not.
Posted: Fri Sep 18, 2009 12:09 pm
by desjardd
Hello,
Thank but that was exactly what I was trying to avoid.
We needed to check if the OS was Vista or newer so we ended up reading the registry key HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\CurrentVersion and checking if it was grater than 5.2 which is Win 2003.
Only 1 if to check
Thanks!
Posted: Mon Sep 21, 2009 5:14 pm
by DevilSun
Oh, you could have just used "Check File Version" on the cmd.exe or something system like that as well, just another thought as another way to do it if you have a single easy check like that.
Posted: Mon Mar 08, 2010 4:51 pm
by Tiago
Great!
How can I use that to detect if I'm using either Windows XP Professional or Windows XP Home?
Thanks in advance!
Posted: Mon Mar 08, 2010 6:35 pm
by CandiceJones
You can actually use Get OS or SP Level to nail down the EXACT OS or SP level you are running on (this command doesn't check for an "at least" match but for an "exact" match).
Posted: Tue Mar 09, 2010 7:48 am
by Tiago
Hi, Candice!
I have already tried
Get Exact OS or SP Level, but it just returns "XP", not "XPHome" or "XPPro", so it won't help much in my case...
By the way, just got a reply from Michael in other topic (
http://www.installaware.com/forums/view ... 9484#19484) that gives some tidbits on
WinXPPro, but it seems it will take some additional research to find out how to catch
WinXPHome.
Hopefully it might help a little!
Thank you!