Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Windows 64bit > Best Way to get version from registry?

Reply
Thread Tools

Best Way to get version from registry?

 
 
Charlie Russel - MVP
Guest
Posts: n/a
 
      06-09-2007
Trying to do some manipulation in PowerShell, and it's easy enough for me to
get what OS I'm on for most versions of Windows. But Server 2k3 and XP x64
both report build # 3790. How to tell which is which?

switch -regex (cmd /c ver) {
2600 {$ver="XP"}
3790 {$ver="Server 2003"}
6000 {$ver="Vista"}
6001 {$ver="Server 2008"}
}

Obviously, this doesn't help if what I actually have is XP x64, since it
comes back as 3790 too.

--
Charlie.
http://msmvps.com/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel


 
Reply With Quote
 
 
 
 
Tony Sperling
Guest
Posts: n/a
 
      06-09-2007
I have a vague perception of the version num's having both a 'Major' and a
'Minor' part. . .


Tony. . .


"Charlie Russel - MVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Trying to do some manipulation in PowerShell, and it's easy enough for me

to
> get what OS I'm on for most versions of Windows. But Server 2k3 and XP x64
> both report build # 3790. How to tell which is which?
>
> switch -regex (cmd /c ver) {
> 2600 {$ver="XP"}
> 3790 {$ver="Server 2003"}
> 6000 {$ver="Vista"}
> 6001 {$ver="Server 2008"}
> }
>
> Obviously, this doesn't help if what I actually have is XP x64, since it
> comes back as 3790 too.
>
> --
> Charlie.
> http://msmvps.com/xperts64
> http://mvp.support.microsoft.com/profile/charlie.russel
>
>



 
Reply With Quote
 
 
 
 
Charlie Russel - MVP
Guest
Posts: n/a
 
      06-09-2007
yes, but that won't distinguish between XP x64 and Server 2k3 - they should
be the same. I'm sure there's other ways - I haven't really started poking
around enough to know, yet. Certainly my method of figuring out what machine
type I'm on is less than efficient (I mean, really, calling a shell to run
"ver"? How brain dead is that?!) But it was mostly just poking and proding
some PowerShell stuff as part of the overall learning experience. But it got
me to thinking, and I was / am interested to hear what folks think is the
best way to suck this information out. (Getting registry values in
PowerShell is trivial, so that's why I asked it as a registry question.)

--
Charlie.
http://msmvps.com/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel


"Tony Sperling" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a vague perception of the version num's having both a 'Major' and a
> 'Minor' part. . .
>
>
> Tony. . .
>
>
> "Charlie Russel - MVP" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Trying to do some manipulation in PowerShell, and it's easy enough for me

> to
>> get what OS I'm on for most versions of Windows. But Server 2k3 and XP
>> x64
>> both report build # 3790. How to tell which is which?
>>
>> switch -regex (cmd /c ver) {
>> 2600 {$ver="XP"}
>> 3790 {$ver="Server 2003"}
>> 6000 {$ver="Vista"}
>> 6001 {$ver="Server 2008"}
>> }
>>
>> Obviously, this doesn't help if what I actually have is XP x64, since it
>> comes back as 3790 too.
>>
>> --
>> Charlie.
>> http://msmvps.com/xperts64
>> http://mvp.support.microsoft.com/profile/charlie.russel
>>
>>

>
>


 
Reply With Quote
 
Tony Sperling
Guest
Posts: n/a
 
      06-09-2007
Well, I also guess we do not really know what variable in the reg. 'ver' is
reading - I had a look and if it reads


HK_L_M/Software/Microsoft/WindowsNT/Currentversion/CurrentBuildNumber

then that is '3790' on my side. However, there is also a

HK_L_M/Software/Microsoft/WindowsNT/CurrentVersion/CurrentVersion
(No - my keyboard isn't stuttering. Not this time!) that says:

'5.2', which would conform to my idea of the 'Major/Minor' version format I
was thinking about. It is also a 'standard string'.

What is that saying on your Server2003, I wonder?

I wouldn't be surprised if Win2k is '5.0' - XP '5.1', as an example.


Tony. . .



 
Reply With Quote
 
Theo
Guest
Posts: n/a
 
      06-09-2007
Version 5.2 is the version number for all version of Windows
with the Server 2003 kernel; x86, ia64 & x64; both Server
2003 and Windows XP Pro.

And you're right about 5.0 & 5.1.


Tony Sperling wrote:
> Well, I also guess we do not really know what variable in the reg. 'ver' is
> reading - I had a look and if it reads
>
>
> HK_L_M/Software/Microsoft/WindowsNT/Currentversion/CurrentBuildNumber
>
> then that is '3790' on my side. However, there is also a
>
> HK_L_M/Software/Microsoft/WindowsNT/CurrentVersion/CurrentVersion
> (No - my keyboard isn't stuttering. Not this time!) that says:
>
> '5.2', which would conform to my idea of the 'Major/Minor' version format I
> was thinking about. It is also a 'standard string'.
>
> What is that saying on your Server2003, I wonder?
>
> I wouldn't be surprised if Win2k is '5.0' - XP '5.1', as an example.
>
>
> Tony. . .
>
>
>

 
Reply With Quote
 
Darrell Gorter[MSFT]
Guest
Posts: n/a
 
      06-09-2007
Hello,
Proably not the correct way, but you can use the MPC designator found in
the productid field
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
ProductID=xxxxx-xxx-xxxxxxx-xxxxx
MPC is the first 5 digits
MPC is Microsoft Product Code and is unique per SKU
Windows XP Professional x64 edition is 76588
This lists the Windows Server 2003 MPC codes:
889713 How to determine the channel that your copy of Windows Server 2003
was obtained through
http://support.microsoft.com/default...b;EN-US;889713


Thanks,
Darrell Gorter[MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights
--------------------
>From: "Tony Sperling" <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
<(E-Mail Removed)>
>Subject: Re: Best Way to get version from registry?
>Date: Sat, 9 Jun 2007 19:37:13 +0200
>Lines: 23
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1807
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896
>X-Antivirus: avast! (VPS 000748-2, 09-06-2007), Outbound message
>X-Antivirus-Status: Clean
>Message-ID: <(E-Mail Removed)>
>Newsgroups: microsoft.public.windows.64bit.general
>NNTP-Posting-Host: 82.143.202.10
>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP02.phx.gbl
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.windows.64bit.general:7230
>X-Tomcat-NG: microsoft.public.windows.64bit.general
>
>Well, I also guess we do not really know what variable in the reg. 'ver' is
>reading - I had a look and if it reads
>
>
>HK_L_M/Software/Microsoft/WindowsNT/Currentversion/CurrentBuildNumber
>
>then that is '3790' on my side. However, there is also a
>
> HK_L_M/Software/Microsoft/WindowsNT/CurrentVersion/CurrentVersion
>(No - my keyboard isn't stuttering. Not this time!) that says:
>
>'5.2', which would conform to my idea of the 'Major/Minor' version format I
>was thinking about. It is also a 'standard string'.
>
>What is that saying on your Server2003, I wonder?
>
>I wouldn't be surprised if Win2k is '5.0' - XP '5.1', as an example.
>
>
>Tony. . .
>
>
>
>


 
Reply With Quote
 
Tony Sperling
Guest
Posts: n/a
 
      06-09-2007
Too, bad - thanks, I was certain that the Server Line had a distinct Minor -
Luckily, though, there is also a 'ProductName' variable that says:

Microsoft Windows XP

unless this too is duplicated across versions, there should consequently be
a XP 5.1 and a XP 5.2?


Tony. . .


"Theo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Version 5.2 is the version number for all version of Windows
> with the Server 2003 kernel; x86, ia64 & x64; both Server
> 2003 and Windows XP Pro.
>
> And you're right about 5.0 & 5.1.
>
>
> Tony Sperling wrote:
> > Well, I also guess we do not really know what variable in the reg. 'ver'

is
> > reading - I had a look and if it reads
> >
> >
> > HK_L_M/Software/Microsoft/WindowsNT/Currentversion/CurrentBuildNumber
> >
> > then that is '3790' on my side. However, there is also a
> >
> >

HK_L_M/Software/Microsoft/WindowsNT/CurrentVersion/CurrentVersion
> > (No - my keyboard isn't stuttering. Not this time!) that says:
> >
> > '5.2', which would conform to my idea of the 'Major/Minor' version

format I
> > was thinking about. It is also a 'standard string'.
> >
> > What is that saying on your Server2003, I wonder?
> >
> > I wouldn't be surprised if Win2k is '5.0' - XP '5.1', as an example.
> >
> >
> > Tony. . .
> >
> >
> >



 
Reply With Quote
 
Theo
Guest
Posts: n/a
 
      06-09-2007
Yes. XP 5.1 is XP-32 bit and XP 5.2 is XP-64 bit.


Tony Sperling wrote:
> Too, bad - thanks, I was certain that the Server Line had a distinct Minor -
> Luckily, though, there is also a 'ProductName' variable that says:
>
> Microsoft Windows XP
>
> unless this too is duplicated across versions, there should consequently be
> a XP 5.1 and a XP 5.2?
>
>
> Tony. . .
>
>
> "Theo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Version 5.2 is the version number for all version of Windows
>> with the Server 2003 kernel; x86, ia64 & x64; both Server
>> 2003 and Windows XP Pro.
>>
>> And you're right about 5.0 & 5.1.
>>
>>
>> Tony Sperling wrote:
>>> Well, I also guess we do not really know what variable in the reg. 'ver'

> is
>>> reading - I had a look and if it reads
>>>
>>>
>>> HK_L_M/Software/Microsoft/WindowsNT/Currentversion/CurrentBuildNumber
>>>
>>> then that is '3790' on my side. However, there is also a
>>>
>>>

> HK_L_M/Software/Microsoft/WindowsNT/CurrentVersion/CurrentVersion
>>> (No - my keyboard isn't stuttering. Not this time!) that says:
>>>
>>> '5.2', which would conform to my idea of the 'Major/Minor' version

> format I
>>> was thinking about. It is also a 'standard string'.
>>>
>>> What is that saying on your Server2003, I wonder?
>>>
>>> I wouldn't be surprised if Win2k is '5.0' - XP '5.1', as an example.
>>>
>>>
>>> Tony. . .
>>>
>>>
>>>

>
>

 
Reply With Quote
 
Homer J. Simpson
Guest
Posts: n/a
 
      06-09-2007
> Trying to do some manipulation in PowerShell, and it's easy enough for me
> to get what OS I'm on for most versions of Windows. But Server 2k3 and XP
> x64 both report build # 3790. How to tell which is which?
>
> switch -regex (cmd /c ver) {
> 2600 {$ver="XP"}
> 3790 {$ver="Server 2003"}
> 6000 {$ver="Vista"}
> 6001 {$ver="Server 2008"}
> }
>
> Obviously, this doesn't help if what I actually have is XP x64, since it
> comes back as 3790 too.


Can you call a C-style API with PowerShell? If so, GetVersionEx() will fill
an OSVERSIONINFO structure. Once you've established that you have version
5.2 (build 3790), then to distinguish between XP x64 and 2003, look at the
OSVERSIONFINO's ProductType member. If it's VER_NT_WORKSTATION (1), you
have XP x64. If it's either VER_NT_DOMAIN_CONTROLLER (2) or VER_NT_SERVER
(3), you have Server 2003.

If you can't rely on calling a Windows API, then I think this information
should still be of value--I remember seeing all the OSVERSIONINFO structure
members *somewhere* in the registry, so it should "only" be a matter of
getting that data, and then doing the mapping the same way once you have it.
Unfortunately I don't have the key in front of me...but it's probably
somewhere close to one of the other ones mentioned elsewhere in this thread.


 
Reply With Quote
 
Charlie Russel - MVP
Guest
Posts: n/a
 
      06-09-2007
Interesting thought, Homer. I'm not sure how I'd call that API, but I might
be able to. Have to think about this a bit more...

(this is the fun part of computers, btw. I _love_ coming up with ways to do
things like this.)

--
Charlie.
http://msmvps.com/xperts64
http://mvp.support.microsoft.com/profile/charlie.russel


"Homer J. Simpson" <root@127.0.0.1> wrote in message
news:%(E-Mail Removed)...
>> Trying to do some manipulation in PowerShell, and it's easy enough for me
>> to get what OS I'm on for most versions of Windows. But Server 2k3 and XP
>> x64 both report build # 3790. How to tell which is which?
>>
>> switch -regex (cmd /c ver) {
>> 2600 {$ver="XP"}
>> 3790 {$ver="Server 2003"}
>> 6000 {$ver="Vista"}
>> 6001 {$ver="Server 2008"}
>> }
>>
>> Obviously, this doesn't help if what I actually have is XP x64, since it
>> comes back as 3790 too.

>
> Can you call a C-style API with PowerShell? If so, GetVersionEx() will
> fill an OSVERSIONINFO structure. Once you've established that you have
> version 5.2 (build 3790), then to distinguish between XP x64 and 2003,
> look at the OSVERSIONFINO's ProductType member. If it's
> VER_NT_WORKSTATION (1), you have XP x64. If it's either
> VER_NT_DOMAIN_CONTROLLER (2) or VER_NT_SERVER (3), you have Server 2003.
>
> If you can't rely on calling a Windows API, then I think this information
> should still be of value--I remember seeing all the OSVERSIONINFO
> structure members *somewhere* in the registry, so it should "only" be a
> matter of getting that data, and then doing the mapping the same way once
> you have it. Unfortunately I don't have the key in front of me...but it's
> probably somewhere close to one of the other ones mentioned elsewhere in
> this thread.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
How to get the 32 bit version of explorer to be the default instead of the 64bit version of Explorer? Thanks! Manquala@gmail.com Windows 64bit 1 02-23-2006 12:36 AM
best way to version tag a java file steve Java 10 08-19-2004 06:20 PM



Advertisments