OS Detection Ambiguity

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

OS Detection Ambiguity

Postby H4nd0 » Tue Nov 14, 2006 6:28 am

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:

Postby MichaelNesmith » Tue Nov 14, 2006 11:30 am

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
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

H4nd0
Posts: 92
Joined: Thu Nov 09, 2006 8:16 am
Location: Sydney, AU
Contact:

Postby H4nd0 » Tue Nov 14, 2006 3:24 pm

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

Postby mberterm » Mon Nov 27, 2006 5:07 pm

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:

Postby desjardd » Fri Sep 18, 2009 10:53 am

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

Postby DevilSun » Fri Sep 18, 2009 11:55 am

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:

Postby desjardd » Fri Sep 18, 2009 12:09 pm

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

Postby DevilSun » Mon Sep 21, 2009 5:14 pm

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

Postby Tiago » Mon Mar 08, 2010 4:51 pm

Great!

How can I use that to detect if I'm using either Windows XP Professional or Windows XP Home?

Thanks in advance!
Tiago Rocha
Product Technology
www.ppi-multitask.com.br

CandiceJones
Posts: 904
Joined: Thu Dec 22, 2005 7:03 pm
Contact:

Postby CandiceJones » Mon Mar 08, 2010 6:35 pm

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
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

Tiago
Posts: 129
Joined: Thu Jun 18, 2009 9:08 am

Postby Tiago » Tue Mar 09, 2010 7:48 am

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/viewtopic.php?p=19484#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!
Tiago Rocha

Product Technology

www.ppi-multitask.com.br


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 73 guests