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

Re: Best Way to get version from registry? by Tony

Tony
Sat Jun 09 05:35:58 CDT 2007

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


Tony. . .


"Charlie Russel - MVP" <charlie@mvKILLALLSPAMMERSps.org> wrote in message
news:634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com...
> 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
>
>



Re: Best Way to get version from registry? by Charlie

Charlie
Sat Jun 09 09:06:44 CDT 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" <tony.sperling@dbREMOVEmail.dk> wrote in message
news:OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl...
>I have a vague perception of the version num's having both a 'Major' and a
> 'Minor' part. . .
>
>
> Tony. . .
>
>
> "Charlie Russel - MVP" <charlie@mvKILLALLSPAMMERSps.org> wrote in message
> news:634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com...
>> 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
>>
>>
>
>


Re: Best Way to get version from registry? by Tony

Tony
Sat Jun 09 12:37:13 CDT 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. . .




Re: Best Way to get version from registry? by Theo

Theo
Sat Jun 09 13:05:57 CDT 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. . .
>
>
>

Re: Best Way to get version from registry? by Darrellg

Darrellg
Sat Jun 09 13:09:34 CDT 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.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" <tony.sperling@dbREMOVEmail.dk>
>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com>
<OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl>
<03169ABE-7A8B-4741-A461-BCFE4F2FEAF5@microsoft.com>
>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: <O2ebQzrqHHA.4740@TK2MSFTNGP02.phx.gbl>
>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. . .
>
>
>
>


Re: Best Way to get version from registry? by Tony

Tony
Sat Jun 09 13:43:07 CDT 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" <theo@discussions.microsoft.com> wrote in message
news:uzNvYDsqHHA.4280@TK2MSFTNGP05.phx.gbl...
> 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. . .
> >
> >
> >



Re: Best Way to get version from registry? by Theo

Theo
Sat Jun 09 14:02:30 CDT 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" <theo@discussions.microsoft.com> wrote in message
> news:uzNvYDsqHHA.4280@TK2MSFTNGP05.phx.gbl...
>> 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. . .
>>>
>>>
>>>
>
>

Re: Best Way to get version from registry? by Homer

Homer
Sat Jun 09 14:31:57 CDT 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.



Re: Best Way to get version from registry? by Charlie

Charlie
Sat Jun 09 16:33:15 CDT 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:%23IMbizsqHHA.3248@TK2MSFTNGP03.phx.gbl...
>> 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.
>
>


Re: Best Way to get version from registry? by Charlie

Charlie
Sat Jun 09 16:35:12 CDT 2007

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" <theo@discussions.microsoft.com> wrote in message
news:O3HI$isqHHA.500@TK2MSFTNGP02.phx.gbl...
> 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" <theo@discussions.microsoft.com> wrote in message
>> news:uzNvYDsqHHA.4280@TK2MSFTNGP05.phx.gbl...
>>> 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. . .
>>>>
>>>>
>>>>
>>

Re: Best Way to get version from registry? by Charlie

Charlie
Sat Jun 09 16:35:23 CDT 2007

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]"" <Darrellg@online.microsoft.com> wrote in message
news:xesZbFsqHHA.1032@TK2MSFTNGHUB02.phx.gbl...
> 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" <tony.sperling@dbREMOVEmail.dk>
>>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com>
> <OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl>
> <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5@microsoft.com>
>>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: <O2ebQzrqHHA.4740@TK2MSFTNGP02.phx.gbl>
>>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. . .
>>
>>
>>
>>
>


Re: Best Way to get version from registry? by Tony

Tony
Sat Jun 09 18:13:19 CDT 2007



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




Re: Best Way to get version from registry? by Charlie

Charlie
Sat Jun 09 19:13:55 CDT 2007

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]"" <Darrellg@online.microsoft.com> wrote in message
news:xesZbFsqHHA.1032@TK2MSFTNGHUB02.phx.gbl...
> 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" <tony.sperling@dbREMOVEmail.dk>
>>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com>
> <OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl>
> <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5@microsoft.com>
>>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: <O2ebQzrqHHA.4740@TK2MSFTNGP02.phx.gbl>
>>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. . .
>>
>>
>>
>>
>


Re: Best Way to get version from registry? by Tony

Tony
Sun Jun 10 05:57:55 CDT 2007

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" <charlie@mvKILLALLSPAMMERSps.org> wrote in message
news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47@microsoft.com...
> 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]"" <Darrellg@online.microsoft.com> wrote in message
> news:xesZbFsqHHA.1032@TK2MSFTNGHUB02.phx.gbl...
> > 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" <tony.sperling@dbREMOVEmail.dk>
> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com>
> > <OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl>
> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5@microsoft.com>
> >>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: <O2ebQzrqHHA.4740@TK2MSFTNGP02.phx.gbl>
> >>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. . .
> >>
> >>
> >>
> >>
> >
>



Re: Best Way to get version from registry? by Charlie

Charlie
Sun Jun 10 10:12:58 CDT 2007

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" <tony.sperling@dbREMOVEmail.dk> wrote in message
news:urMyy40qHHA.4100@TK2MSFTNGP06.phx.gbl...
>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" <charlie@mvKILLALLSPAMMERSps.org> wrote in message
> news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47@microsoft.com...
>> 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]"" <Darrellg@online.microsoft.com> wrote in message
>> news:xesZbFsqHHA.1032@TK2MSFTNGHUB02.phx.gbl...
>> > 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" <tony.sperling@dbREMOVEmail.dk>
>> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433@microsoft.com>
>> > <OEHs3HoqHHA.192@TK2MSFTNGP02.phx.gbl>
>> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5@microsoft.com>
>> >>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: <O2ebQzrqHHA.4740@TK2MSFTNGP02.phx.gbl>
>> >>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. . .
>> >>
>> >>
>> >>
>> >>
>> >
>>
>
>


Re: Best Way to get version from registry? by Charlie

Charlie
Sun Jun 10 12:23:44 CDT 2007

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" <tony.sperling@dbREMOVEmail.dk> wrote in message
news:ebfJWvuqHHA.1172@TK2MSFTNGP03.phx.gbl...
>
>
> (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 r