OS Detection Ambiguity

Got a problem you cannot solve? Try here.
Post Reply
H4nd0
Posts: 92
Joined: Thu Nov 09, 2006 8:16 am
Location: Sydney, AU
Contact:

OS Detection Ambiguity

Post 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)
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
H4nd0
Posts: 92
Joined: Thu Nov 09, 2006 8:16 am
Location: Sydney, AU
Contact:

Post 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.

:)
mberterm
Posts: 5
Joined: Mon Nov 27, 2006 3:47 pm

MSI OS properties

Post 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
desjardd
Posts: 5
Joined: Fri Aug 21, 2009 9:52 am
Location: Montreal
Contact:

Post by desjardd »

can anyone elaborate on how we can do this? We are using v9.

Thanks!
DevilSun
Posts: 19
Joined: Wed Jul 01, 2009 6:11 pm
Location: Oregon

Post 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.
desjardd
Posts: 5
Joined: Fri Aug 21, 2009 9:52 am
Location: Montreal
Contact:

Post 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!
DevilSun
Posts: 19
Joined: Wed Jul 01, 2009 6:11 pm
Location: Oregon

Post 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.
Tiago
Posts: 129
Joined: Thu Jun 18, 2009 9:08 am

Post 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!
[b]Tiago Rocha[/b]
[i]Product Technology[/i]
www.ppi-multitask.com.br
CandiceJones
Posts: 904
Joined: Thu Dec 22, 2005 7:03 pm
Contact:

Post 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).
Candice Jones
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Tiago
Posts: 129
Joined: Thu Jun 18, 2009 9:08 am

Post 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!
[b]Tiago Rocha[/b]
[i]Product Technology[/i]
www.ppi-multitask.com.br
Post Reply