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)
OS Detection Ambiguity
-
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
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/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
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.
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
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
Operating System Property Values
http://msdn.microsoft.com/library/en-us ... values.asp
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:
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.
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.
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!
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!
-
- Posts: 904
- Joined: Thu Dec 22, 2005 7:03 pm
- Contact:
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/
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/
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!
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!
Who is online
Users browsing this forum: Google [Bot] and 73 guests