Best Way to get version from registry?

Discussion in 'Windows 64bit' started by Charlie Russel - MVP, Jun 9, 2007.

  1. 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
    Charlie Russel - MVP, Jun 9, 2007
    #1
    1. Advertising

  2. I have a vague perception of the version num's having both a 'Major' and a
    'Minor' part. . .


    Tony. . .


    "Charlie Russel - MVP" <> wrote in message
    news:...
    > 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
    >
    >
    Tony Sperling, Jun 9, 2007
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    >I have a vague perception of the version num's having both a 'Major' and a
    > 'Minor' part. . .
    >
    >
    > Tony. . .
    >
    >
    > "Charlie Russel - MVP" <> wrote in message
    > news:...
    >> 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
    >>
    >>

    >
    >
    Charlie Russel - MVP, Jun 9, 2007
    #3
  4. 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. . .
    Tony Sperling, Jun 9, 2007
    #4
  5. Charlie Russel - MVP

    Theo Guest

    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. . .
    >
    >
    >
    Theo, Jun 9, 2007
    #5
  6. 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.aspx?scid=kb;EN-US;889713


    Thanks,
    Darrell Gorter[MSFT]

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

    <>
    <>
    >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: <>
    >Newsgroups: microsoft.public.windows.64bit.general
    >NNTP-Posting-Host: 82.143.202.10
    >Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    >
    >
    >
    >
    Darrell Gorter[MSFT], Jun 9, 2007
    #6
  7. 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" <> wrote in message
    news:...
    > 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. . .
    > >
    > >
    > >
    Tony Sperling, Jun 9, 2007
    #7
  8. Charlie Russel - MVP

    Theo Guest

    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" <> wrote in message
    > news:...
    >> 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. . .
    >>>
    >>>
    >>>

    >
    >
    Theo, Jun 9, 2007
    #8
  9. > 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.
    Homer J. Simpson, Jun 9, 2007
    #9
  10. 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:%...
    >> 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.
    >
    >
    Charlie Russel - MVP, Jun 9, 2007
    #10
  11. yes, I could get at it that way. Let me poke around a bit...

    But I admit, I'm liking Darrell's so far. It's a simple match to get it -
    very low cost and since there's only one possible answer that is XP x64,
    that should work.

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


    "Theo" <> wrote in message
    news:O3HI$...
    > 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" <> wrote in message
    >> news:...
    >>> 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. . .
    >>>>
    >>>>
    >>>>

    >>
    Charlie Russel - MVP, Jun 9, 2007
    #11
  12. Now that's an interesting way. It's got a problem expanding to do more than
    distinguish between XP x64 and Server 2k3, but it certainly would be a
    simple check.

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


    ""Darrell Gorter[MSFT]"" <> wrote in message
    news:...
    > 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.aspx?scid=kb;EN-US;889713
    >
    >
    > Thanks,
    > Darrell Gorter[MSFT]
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights
    > --------------------
    >>From: "Tony Sperling" <>
    >>References: <>

    > <>
    > <>
    >>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: <>
    >>Newsgroups: microsoft.public.windows.64bit.general
    >>NNTP-Posting-Host: 82.143.202.10
    >>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    >>
    >>
    >>
    >>

    >
    Charlie Russel - MVP, Jun 9, 2007
    #12
  13. (this is the fun part of computers, btw. I _love_ coming up with ways to do
    things like this.)

    ---------------

    That's exactly right, too many programmers hold the opinion that 'scripting'
    isn't programming at all - but it's really only with limited commands and
    functions that your creativity is tested, the rest is knowing the sequence
    of which buttons to press.

    Neil J. Rubenking was probably the only idol I ever looked up to - what he
    could do in DOS with Batch must have been the most advanced programming
    exhibited on this planet!


    Tony. . .
    Tony Sperling, Jun 10, 2007
    #13
  14. OK, so we're now at:

    $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    NT/CurrentVersion').getvalue('ProductID')
    $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    NT/CurrentVersion').getvalue('CurrentBuildNumber')
    switch -regex ($Build) {
    2600 { $ver="XP" }
    3790 { if ($ProductID -match "76588-") {
    $ver = "XP"} else {$ver = "Server 2003" }
    }
    6000 { $ver="Vista" }
    6001 { $ver="Longhorn" }
    }
    $arch = $env:processor_architecture

    Not very elegant yet - sucking all of CurrentVersion into a hashtable would
    be more elegant and have some added benefits downstream. But this is
    functional and more efficient that the (cmd /c ver) business.
    --
    Charlie.
    http://msmvps.com/xperts64
    http://mvp.support.microsoft.com/profile/charlie.russel


    ""Darrell Gorter[MSFT]"" <> wrote in message
    news:...
    > 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.aspx?scid=kb;EN-US;889713
    >
    >
    > Thanks,
    > Darrell Gorter[MSFT]
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights
    > --------------------
    >>From: "Tony Sperling" <>
    >>References: <>

    > <>
    > <>
    >>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: <>
    >>Newsgroups: microsoft.public.windows.64bit.general
    >>NNTP-Posting-Host: 82.143.202.10
    >>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    >>
    >>
    >>
    >>

    >
    Charlie Russel - MVP, Jun 10, 2007
    #14
  15. I assume that the PID value should be holding the same kind of information
    for all versions, remains to make the interpretation for all versions. That
    would let you execute the whole thing from a "printf() statement - if
    PowerShell has such a thing in it's arsenal?


    Tony. . .


    "Charlie Russel - MVP" <> wrote in message
    news:...
    > OK, so we're now at:
    >
    > $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    > NT/CurrentVersion').getvalue('ProductID')
    > $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    > NT/CurrentVersion').getvalue('CurrentBuildNumber')
    > switch -regex ($Build) {
    > 2600 { $ver="XP" }
    > 3790 { if ($ProductID -match "76588-") {
    > $ver = "XP"} else {$ver = "Server 2003" }
    > }
    > 6000 { $ver="Vista" }
    > 6001 { $ver="Longhorn" }
    > }
    > $arch = $env:processor_architecture
    >
    > Not very elegant yet - sucking all of CurrentVersion into a hashtable

    would
    > be more elegant and have some added benefits downstream. But this is
    > functional and more efficient that the (cmd /c ver) business.
    > --
    > Charlie.
    > http://msmvps.com/xperts64
    > http://mvp.support.microsoft.com/profile/charlie.russel
    >
    >
    > ""Darrell Gorter[MSFT]"" <> wrote in message
    > news:...
    > > 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.aspx?scid=kb;EN-US;889713
    > >
    > >
    > > Thanks,
    > > Darrell Gorter[MSFT]
    > >
    > > This posting is provided "AS IS" with no warranties, and confers no

    rights
    > > --------------------
    > >>From: "Tony Sperling" <>
    > >>References: <>

    > > <>
    > > <>
    > >>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: <>
    > >>Newsgroups: microsoft.public.windows.64bit.general
    > >>NNTP-Posting-Host: 82.143.202.10
    > >>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    > >>
    > >>
    > >>
    > >>

    > >

    >
    Tony Sperling, Jun 10, 2007
    #15
  16. Oh, it's got a printf equivalent alright. Like printf on steroids is more
    like it.

    The problem with the PID information is that it is a bit messy - there's a
    different one for every SKU. Well, no, not quite. There's some duplication
    where the SKUs are equivalent. But you'd have to parse for trial, eval, oem,
    VL, retail, etc. across each possible version. So Windows Server gets really
    ugly.

    All I really want and need is in the registry at
    HKLM:/Software/Microsoft/Windows NT/CurrentVersion. Sucking those values
    into a hashtable would be the cleanest, but I just came up empty trying to
    do that and was tired. So grabbed the two I wanted at the moment and let it
    go. Left the clean version for a future date.

    If you haven't played with PowerShell, you should. It's the future of
    scripting on Windows, and it is amazing. It's not perfect, goodness knows,
    but it will grow over time. And was designed by UNIX geeks who "get" shells.
    There's many things I want added to it, but it's very useful now. I just
    need to get to where I'm thinking in it, and that's slow. At this point,
    it's all a translation and having to look things up. But I'm forcing myself
    to use it as my default command line shell, and trying to extend my
    knowledge a little bit every day.

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


    "Tony Sperling" <> wrote in message
    news:...
    >I assume that the PID value should be holding the same kind of information
    > for all versions, remains to make the interpretation for all versions.
    > That
    > would let you execute the whole thing from a "printf() statement - if
    > PowerShell has such a thing in it's arsenal?
    >
    >
    > Tony. . .
    >
    >
    > "Charlie Russel - MVP" <> wrote in message
    > news:...
    >> OK, so we're now at:
    >>
    >> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    >> NT/CurrentVersion').getvalue('ProductID')
    >> $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    >> NT/CurrentVersion').getvalue('CurrentBuildNumber')
    >> switch -regex ($Build) {
    >> 2600 { $ver="XP" }
    >> 3790 { if ($ProductID -match "76588-") {
    >> $ver = "XP"} else {$ver = "Server 2003" }
    >> }
    >> 6000 { $ver="Vista" }
    >> 6001 { $ver="Longhorn" }
    >> }
    >> $arch = $env:processor_architecture
    >>
    >> Not very elegant yet - sucking all of CurrentVersion into a hashtable

    > would
    >> be more elegant and have some added benefits downstream. But this is
    >> functional and more efficient that the (cmd /c ver) business.
    >> --
    >> Charlie.
    >> http://msmvps.com/xperts64
    >> http://mvp.support.microsoft.com/profile/charlie.russel
    >>
    >>
    >> ""Darrell Gorter[MSFT]"" <> wrote in message
    >> news:...
    >> > 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.aspx?scid=kb;EN-US;889713
    >> >
    >> >
    >> > Thanks,
    >> > Darrell Gorter[MSFT]
    >> >
    >> > This posting is provided "AS IS" with no warranties, and confers no

    > rights
    >> > --------------------
    >> >>From: "Tony Sperling" <>
    >> >>References: <>
    >> > <>
    >> > <>
    >> >>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: <>
    >> >>Newsgroups: microsoft.public.windows.64bit.general
    >> >>NNTP-Posting-Host: 82.143.202.10
    >> >>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    >> >>
    >> >>
    >> >>
    >> >>
    >> >

    >>

    >
    >
    Charlie Russel - MVP, Jun 10, 2007
    #16
  17. Indeed. Neil was always an inspiration. I learned many things from his
    scripts.

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


    "Tony Sperling" <> wrote in message
    news:...
    >
    >
    > (this is the fun part of computers, btw. I _love_ coming up with ways to
    > do
    > things like this.)
    >
    > ---------------
    >
    > That's exactly right, too many programmers hold the opinion that
    > 'scripting'
    > isn't programming at all - but it's really only with limited commands and
    > functions that your creativity is tested, the rest is knowing the sequence
    > of which buttons to press.
    >
    > Neil J. Rubenking was probably the only idol I ever looked up to - what he
    > could do in DOS with Batch must have been the most advanced programming
    > exhibited on this planet!
    >
    >
    > Tony. . .
    >
    >
    >
    Charlie Russel - MVP, Jun 10, 2007
    #17
  18. He, he. . .I'm thinking you have something a little more advanced in mind
    than your original post indicated?

    What would be interesting in this context, would be if there was some
    mathematical logic behind the MPC and it's generation - then it could
    possibly be adapted to work with future releases, which I believe is one of
    your real concerns - that you are having an ever changing menagerie of OS's
    to evaluate.

    If not, you most likely will have to re-write this continuously, and you may
    shorten your ordeal if you limit the parsing to the stuff you need at the
    moment. This will be plenty messy already, as you are envisioning, and
    something that resolves all possibilities will have the elegance, sure, but
    weigh in the work and that will have a tendency to subtract from that
    elegance and the 'hard-coding' may attract it's own form of elegance
    instead. One version goes and the next one enters, and you re-write that
    test.

    I wuoldn't want to do your coding for you, but some tasks have a way of
    growing exponentialy and I think you will be well adviced to sit down and
    draw the limit before you start. Doing it later is difficult, it'll be like
    dismembering a child.

    As for your advice on PowerShell'ing - I think it very likely that I'll take
    you up on that, sometime. I have very little time at the moment, learning
    something new at my age demands I can rip a fistfull of pages out of the
    calendar. Seeing your example, it's recognizable, (nothing scary) but
    there's bound to be a threshold.

    One other, and completely different thing, is that the other day I stumbled
    onto the manufacturer that continued the good old IBM keyboard - we had an
    exchange about that a while back, it's surprisingly cheap ($69) so perhaps
    not quite the same as it used to be, but it still has the 'buckling spring'
    technology and a nice guarantee period.

    http://www.pckeyboard.com/customizer.html

    if I'm going to do any coding, I'll be needing an English keyboard. And
    sooner, rather than later!


    Tony. . .


    "Charlie Russel - MVP" <> wrote in message
    news:...
    > Oh, it's got a printf equivalent alright. Like printf on steroids is more
    > like it.
    >
    > The problem with the PID information is that it is a bit messy - there's a
    > different one for every SKU. Well, no, not quite. There's some duplication
    > where the SKUs are equivalent. But you'd have to parse for trial, eval,

    oem,
    > VL, retail, etc. across each possible version. So Windows Server gets

    really
    > ugly.
    >
    > All I really want and need is in the registry at
    > HKLM:/Software/Microsoft/Windows NT/CurrentVersion. Sucking those values
    > into a hashtable would be the cleanest, but I just came up empty trying to
    > do that and was tired. So grabbed the two I wanted at the moment and let

    it
    > go. Left the clean version for a future date.
    >
    > If you haven't played with PowerShell, you should. It's the future of
    > scripting on Windows, and it is amazing. It's not perfect, goodness knows,
    > but it will grow over time. And was designed by UNIX geeks who "get"

    shells.
    > There's many things I want added to it, but it's very useful now. I just
    > need to get to where I'm thinking in it, and that's slow. At this point,
    > it's all a translation and having to look things up. But I'm forcing

    myself
    > to use it as my default command line shell, and trying to extend my
    > knowledge a little bit every day.
    >
    > --
    > Charlie.
    > http://msmvps.com/xperts64
    > http://mvp.support.microsoft.com/profile/charlie.russel
    >
    >
    > "Tony Sperling" <> wrote in message
    > news:...
    > >I assume that the PID value should be holding the same kind of

    information
    > > for all versions, remains to make the interpretation for all versions.
    > > That
    > > would let you execute the whole thing from a "printf() statement - if
    > > PowerShell has such a thing in it's arsenal?
    > >
    > >
    > > Tony. . .
    > >
    > >
    > > "Charlie Russel - MVP" <> wrote in

    message
    > > news:...
    > >> OK, so we're now at:
    > >>
    > >> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    > >> NT/CurrentVersion').getvalue('ProductID')
    > >> $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    > >> NT/CurrentVersion').getvalue('CurrentBuildNumber')
    > >> switch -regex ($Build) {
    > >> 2600 { $ver="XP" }
    > >> 3790 { if ($ProductID -match "76588-") {
    > >> $ver = "XP"} else {$ver = "Server 2003" }
    > >> }
    > >> 6000 { $ver="Vista" }
    > >> 6001 { $ver="Longhorn" }
    > >> }
    > >> $arch = $env:processor_architecture
    > >>
    > >> Not very elegant yet - sucking all of CurrentVersion into a hashtable

    > > would
    > >> be more elegant and have some added benefits downstream. But this is
    > >> functional and more efficient that the (cmd /c ver) business.
    > >> --
    > >> Charlie.
    > >> http://msmvps.com/xperts64
    > >> http://mvp.support.microsoft.com/profile/charlie.russel
    > >>
    > >>
    > >> ""Darrell Gorter[MSFT]"" <> wrote in

    message
    > >> news:...
    > >> > 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.aspx?scid=kb;EN-US;889713
    > >> >
    > >> >
    > >> > Thanks,
    > >> > Darrell Gorter[MSFT]
    > >> >
    > >> > This posting is provided "AS IS" with no warranties, and confers no

    > > rights
    > >> > --------------------
    > >> >>From: "Tony Sperling" <>
    > >> >>References: <>
    > >> > <>
    > >> > <>
    > >> >>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: <>
    > >> >>Newsgroups: microsoft.public.windows.64bit.general
    > >> >>NNTP-Posting-Host: 82.143.202.10
    > >> >>Path:

    TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    > >> >>
    > >> >>
    > >> >>
    > >> >>
    > >> >
    > >>

    > >
    > >

    >
    Tony Sperling, Jun 11, 2007
    #18
  19. Fortunately, OS's only get added every few years. ;)

    I really didn't have any particular plan in mind. Just had a behaviour where
    I needed to be different for pre-Vista v. vista and later. And, of course, I
    could simply have hard coded that, but it made me start thinking about it,
    and starting to build a somewhat more general solution. I don't really need
    to do anything serious with it at this point, just recognize when I'm
    dealing with a LUA box or a non-LUA box. That being said, I'm already
    thinking of other ways to use that knowledge, in other locations and
    circumstances. And, as I said - it's part of the learning process as I shift
    my script "thinking" from ksh to PowerShell. My native scripting language is
    certainly ksh, with cmd being next most comfortable. So I have to force
    myself to use PowerShell to do my daily tasks. That will get me to start
    thinking in PS, and from that, I'll slowly start to develop a reasonable
    working vocabulary. At this point, I can barely make myself understood. ;)

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


    "Tony Sperling" <> wrote in message
    news:...
    > He, he. . .I'm thinking you have something a little more advanced in mind
    > than your original post indicated?
    >
    > What would be interesting in this context, would be if there was some
    > mathematical logic behind the MPC and it's generation - then it could
    > possibly be adapted to work with future releases, which I believe is one
    > of
    > your real concerns - that you are having an ever changing menagerie of
    > OS's
    > to evaluate.
    >
    > If not, you most likely will have to re-write this continuously, and you
    > may
    > shorten your ordeal if you limit the parsing to the stuff you need at the
    > moment. This will be plenty messy already, as you are envisioning, and
    > something that resolves all possibilities will have the elegance, sure,
    > but
    > weigh in the work and that will have a tendency to subtract from that
    > elegance and the 'hard-coding' may attract it's own form of elegance
    > instead. One version goes and the next one enters, and you re-write that
    > test.
    >
    > I wuoldn't want to do your coding for you, but some tasks have a way of
    > growing exponentialy and I think you will be well adviced to sit down and
    > draw the limit before you start. Doing it later is difficult, it'll be
    > like
    > dismembering a child.
    >
    > As for your advice on PowerShell'ing - I think it very likely that I'll
    > take
    > you up on that, sometime. I have very little time at the moment, learning
    > something new at my age demands I can rip a fistfull of pages out of the
    > calendar. Seeing your example, it's recognizable, (nothing scary) but
    > there's bound to be a threshold.
    >
    > One other, and completely different thing, is that the other day I
    > stumbled
    > onto the manufacturer that continued the good old IBM keyboard - we had an
    > exchange about that a while back, it's surprisingly cheap ($69) so perhaps
    > not quite the same as it used to be, but it still has the 'buckling
    > spring'
    > technology and a nice guarantee period.
    >
    > http://www.pckeyboard.com/customizer.html
    >
    > if I'm going to do any coding, I'll be needing an English keyboard. And
    > sooner, rather than later!
    >
    >
    > Tony. . .
    >
    >
    > "Charlie Russel - MVP" <> wrote in message
    > news:...
    >> Oh, it's got a printf equivalent alright. Like printf on steroids is more
    >> like it.
    >>
    >> The problem with the PID information is that it is a bit messy - there's
    >> a
    >> different one for every SKU. Well, no, not quite. There's some
    >> duplication
    >> where the SKUs are equivalent. But you'd have to parse for trial, eval,

    > oem,
    >> VL, retail, etc. across each possible version. So Windows Server gets

    > really
    >> ugly.
    >>
    >> All I really want and need is in the registry at
    >> HKLM:/Software/Microsoft/Windows NT/CurrentVersion. Sucking those values
    >> into a hashtable would be the cleanest, but I just came up empty trying
    >> to
    >> do that and was tired. So grabbed the two I wanted at the moment and let

    > it
    >> go. Left the clean version for a future date.
    >>
    >> If you haven't played with PowerShell, you should. It's the future of
    >> scripting on Windows, and it is amazing. It's not perfect, goodness
    >> knows,
    >> but it will grow over time. And was designed by UNIX geeks who "get"

    > shells.
    >> There's many things I want added to it, but it's very useful now. I just
    >> need to get to where I'm thinking in it, and that's slow. At this point,
    >> it's all a translation and having to look things up. But I'm forcing

    > myself
    >> to use it as my default command line shell, and trying to extend my
    >> knowledge a little bit every day.
    >>
    >> --
    >> Charlie.
    >> http://msmvps.com/xperts64
    >> http://mvp.support.microsoft.com/profile/charlie.russel
    >>
    >>
    >> "Tony Sperling" <> wrote in message
    >> news:...
    >> >I assume that the PID value should be holding the same kind of

    > information
    >> > for all versions, remains to make the interpretation for all versions.
    >> > That
    >> > would let you execute the whole thing from a "printf() statement - if
    >> > PowerShell has such a thing in it's arsenal?
    >> >
    >> >
    >> > Tony. . .
    >> >
    >> >
    >> > "Charlie Russel - MVP" <> wrote in

    > message
    >> > news:...
    >> >> OK, so we're now at:
    >> >>
    >> >> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    >> >> NT/CurrentVersion').getvalue('ProductID')
    >> >> $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    >> >> NT/CurrentVersion').getvalue('CurrentBuildNumber')
    >> >> switch -regex ($Build) {
    >> >> 2600 { $ver="XP" }
    >> >> 3790 { if ($ProductID -match "76588-") {
    >> >> $ver = "XP"} else {$ver = "Server 2003" }
    >> >> }
    >> >> 6000 { $ver="Vista" }
    >> >> 6001 { $ver="Longhorn" }
    >> >> }
    >> >> $arch = $env:processor_architecture
    >> >>
    >> >> Not very elegant yet - sucking all of CurrentVersion into a hashtable
    >> > would
    >> >> be more elegant and have some added benefits downstream. But this is
    >> >> functional and more efficient that the (cmd /c ver) business.
    >> >> --
    >> >> Charlie.
    >> >> http://msmvps.com/xperts64
    >> >> http://mvp.support.microsoft.com/profile/charlie.russel
    >> >>
    >> >>
    >> >> ""Darrell Gorter[MSFT]"" <> wrote in

    > message
    >> >> news:...
    >> >> > 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.aspx?scid=kb;EN-US;889713
    >> >> >
    >> >> >
    >> >> > Thanks,
    >> >> > Darrell Gorter[MSFT]
    >> >> >
    >> >> > This posting is provided "AS IS" with no warranties, and confers no
    >> > rights
    >> >> > --------------------
    >> >> >>From: "Tony Sperling" <>
    >> >> >>References: <>
    >> >> > <>
    >> >> > <>
    >> >> >>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: <>
    >> >> >>Newsgroups: microsoft.public.windows.64bit.general
    >> >> >>NNTP-Posting-Host: 82.143.202.10
    >> >> >>Path:

    > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >
    >> >>
    >> >
    >> >

    >>

    >
    >
    Charlie Russel - MVP, Jun 11, 2007
    #19
  20. Yes, well our thinking really is in many ways colored by our language(s),
    and mine is colored by 'C'. I learned the hard way that I cannot afford to
    make patches to my code. If I need a patch, I need to start all over because
    something has been wrong from the begining. Scripting, of course, is
    different - if you need a patch, there won't be much of it around and it
    will be possible to correct and refine (not to mention, completely
    transform) a routine with a simple 'search-and-replace', Perl (Pathetically
    Ecclectic Rubish Lister) is said to be particularly good in that
    department, so I've heard.

    I tried looking for a PS download link, if I want to dip my toes later on, I
    might as well do some reading and testing now, but they only mention PS for
    Vista - further down it is said to be supported all around but no further
    downloads, is it just one single version then?


    Tony. . .



    "Charlie Russel - MVP" <> wrote in message
    news:...
    > Fortunately, OS's only get added every few years. ;)
    >
    > I really didn't have any particular plan in mind. Just had a behaviour

    where
    > I needed to be different for pre-Vista v. vista and later. And, of course,

    I
    > could simply have hard coded that, but it made me start thinking about it,
    > and starting to build a somewhat more general solution. I don't really

    need
    > to do anything serious with it at this point, just recognize when I'm
    > dealing with a LUA box or a non-LUA box. That being said, I'm already
    > thinking of other ways to use that knowledge, in other locations and
    > circumstances. And, as I said - it's part of the learning process as I

    shift
    > my script "thinking" from ksh to PowerShell. My native scripting language

    is
    > certainly ksh, with cmd being next most comfortable. So I have to force
    > myself to use PowerShell to do my daily tasks. That will get me to start
    > thinking in PS, and from that, I'll slowly start to develop a reasonable
    > working vocabulary. At this point, I can barely make myself understood. ;)
    >
    > --
    > Charlie.
    > http://msmvps.com/xperts64
    > http://mvp.support.microsoft.com/profile/charlie.russel
    >
    >
    > "Tony Sperling" <> wrote in message
    > news:...
    > > He, he. . .I'm thinking you have something a little more advanced in

    mind
    > > than your original post indicated?
    > >
    > > What would be interesting in this context, would be if there was some
    > > mathematical logic behind the MPC and it's generation - then it could
    > > possibly be adapted to work with future releases, which I believe is one
    > > of
    > > your real concerns - that you are having an ever changing menagerie of
    > > OS's
    > > to evaluate.
    > >
    > > If not, you most likely will have to re-write this continuously, and you
    > > may
    > > shorten your ordeal if you limit the parsing to the stuff you need at

    the
    > > moment. This will be plenty messy already, as you are envisioning, and
    > > something that resolves all possibilities will have the elegance, sure,
    > > but
    > > weigh in the work and that will have a tendency to subtract from that
    > > elegance and the 'hard-coding' may attract it's own form of elegance
    > > instead. One version goes and the next one enters, and you re-write that
    > > test.
    > >
    > > I wuoldn't want to do your coding for you, but some tasks have a way of
    > > growing exponentialy and I think you will be well adviced to sit down

    and
    > > draw the limit before you start. Doing it later is difficult, it'll be
    > > like
    > > dismembering a child.
    > >
    > > As for your advice on PowerShell'ing - I think it very likely that I'll
    > > take
    > > you up on that, sometime. I have very little time at the moment,

    learning
    > > something new at my age demands I can rip a fistfull of pages out of the
    > > calendar. Seeing your example, it's recognizable, (nothing scary) but
    > > there's bound to be a threshold.
    > >
    > > One other, and completely different thing, is that the other day I
    > > stumbled
    > > onto the manufacturer that continued the good old IBM keyboard - we had

    an
    > > exchange about that a while back, it's surprisingly cheap ($69) so

    perhaps
    > > not quite the same as it used to be, but it still has the 'buckling
    > > spring'
    > > technology and a nice guarantee period.
    > >
    > > http://www.pckeyboard.com/customizer.html
    > >
    > > if I'm going to do any coding, I'll be needing an English keyboard. And
    > > sooner, rather than later!
    > >
    > >
    > > Tony. . .
    > >
    > >
    > > "Charlie Russel - MVP" <> wrote in

    message
    > > news:...
    > >> Oh, it's got a printf equivalent alright. Like printf on steroids is

    more
    > >> like it.
    > >>
    > >> The problem with the PID information is that it is a bit messy -

    there's
    > >> a
    > >> different one for every SKU. Well, no, not quite. There's some
    > >> duplication
    > >> where the SKUs are equivalent. But you'd have to parse for trial, eval,

    > > oem,
    > >> VL, retail, etc. across each possible version. So Windows Server gets

    > > really
    > >> ugly.
    > >>
    > >> All I really want and need is in the registry at
    > >> HKLM:/Software/Microsoft/Windows NT/CurrentVersion. Sucking those

    values
    > >> into a hashtable would be the cleanest, but I just came up empty trying
    > >> to
    > >> do that and was tired. So grabbed the two I wanted at the moment and

    let
    > > it
    > >> go. Left the clean version for a future date.
    > >>
    > >> If you haven't played with PowerShell, you should. It's the future of
    > >> scripting on Windows, and it is amazing. It's not perfect, goodness
    > >> knows,
    > >> but it will grow over time. And was designed by UNIX geeks who "get"

    > > shells.
    > >> There's many things I want added to it, but it's very useful now. I

    just
    > >> need to get to where I'm thinking in it, and that's slow. At this

    point,
    > >> it's all a translation and having to look things up. But I'm forcing

    > > myself
    > >> to use it as my default command line shell, and trying to extend my
    > >> knowledge a little bit every day.
    > >>
    > >> --
    > >> Charlie.
    > >> http://msmvps.com/xperts64
    > >> http://mvp.support.microsoft.com/profile/charlie.russel
    > >>
    > >>
    > >> "Tony Sperling" <> wrote in message
    > >> news:...
    > >> >I assume that the PID value should be holding the same kind of

    > > information
    > >> > for all versions, remains to make the interpretation for all

    versions.
    > >> > That
    > >> > would let you execute the whole thing from a "printf() statement - if
    > >> > PowerShell has such a thing in it's arsenal?
    > >> >
    > >> >
    > >> > Tony. . .
    > >> >
    > >> >
    > >> > "Charlie Russel - MVP" <> wrote in

    > > message
    > >> > news:...
    > >> >> OK, so we're now at:
    > >> >>
    > >> >> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows
    > >> >> NT/CurrentVersion').getvalue('ProductID')
    > >> >> $Build=(get-item 'HKLM:/Software/Microsoft/Windows
    > >> >> NT/CurrentVersion').getvalue('CurrentBuildNumber')
    > >> >> switch -regex ($Build) {
    > >> >> 2600 { $ver="XP" }
    > >> >> 3790 { if ($ProductID -match "76588-") {
    > >> >> $ver = "XP"} else {$ver = "Server 2003" }
    > >> >> }
    > >> >> 6000 { $ver="Vista" }
    > >> >> 6001 { $ver="Longhorn" }
    > >> >> }
    > >> >> $arch = $env:processor_architecture
    > >> >>
    > >> >> Not very elegant yet - sucking all of CurrentVersion into a

    hashtable
    > >> > would
    > >> >> be more elegant and have some added benefits downstream. But this is
    > >> >> functional and more efficient that the (cmd /c ver) business.
    > >> >> --
    > >> >> Charlie.
    > >> >> http://msmvps.com/xperts64
    > >> >> http://mvp.support.microsoft.com/profile/charlie.russel
    > >> >>
    > >> >>
    > >> >> ""Darrell Gorter[MSFT]"" <> wrote in

    > > message
    > >> >> news:...
    > >> >> > 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.aspx?scid=kb;EN-US;889713
    > >> >> >
    > >> >> >
    > >> >> > Thanks,
    > >> >> > Darrell Gorter[MSFT]
    > >> >> >
    > >> >> > This posting is provided "AS IS" with no warranties, and confers

    no
    > >> > rights
    > >> >> > --------------------
    > >> >> >>From: "Tony Sperling" <>
    > >> >> >>References: <>
    > >> >> > <>
    > >> >> > <>
    > >> >> >>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: <>
    > >> >> >>Newsgroups: microsoft.public.windows.64bit.general
    > >> >> >>NNTP-Posting-Host: 82.143.202.10
    > >> >> >>Path:

    > > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.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. . .
    > >> >> >>
    > >> >> >>
    > >> >> >>
    > >> >> >>
    > >> >> >
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >
    Tony Sperling, Jun 11, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil
    Replies:
    174
    Views:
    3,280
    Briscobar
    Apr 17, 2006
  2. Joe
    Replies:
    0
    Views:
    344
  3. wege

    Help:win95 registry vs. winxp registry

    wege, Jun 8, 2006, in forum: Computer Support
    Replies:
    3
    Views:
    636
    Toolman Tim
    Jun 9, 2006
  4. John John

    AMD Opteron: 1-way, 2-way, ... Up to 8-way.

    John John, Dec 24, 2005, in forum: Windows 64bit
    Replies:
    12
    Views:
    784
    Tony Sperling
    Dec 27, 2005
  5. Replies:
    1
    Views:
    419
Loading...

Share This Page