Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: General » microsoft.public.windows.64bit.general
Thread: Best Way to get version from registry?

HTVi
TV Discussion Newsgroups

Best Way to get version from registry?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/9/2007 12:56:05 AM
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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/9/2007 10:35:58 AM
I have a vague perception of the version num's having both a 'Major' and a
'Minor' part. . .


Tony. . .


"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in message
news:634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com...
[Quoted Text]
> 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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/9/2007 2:06:44 PM
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[ at ]dbREMOVEmail.dk> wrote in message
news:OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
>I have a vague perception of the version num's having both a 'Major' and a
> 'Minor' part. . .
>
>
> Tony. . .
>
>
> "Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in message
> news:634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/9/2007 5:37:13 PM
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?
Theo <theo[ at ]discussions.microsoft.com> 6/9/2007 6:05:57 PM
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:
[Quoted Text]
> 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?
Darrellg[ at ]online.microsoft.com ("Darrell Gorter[MSFT]") 6/9/2007 6:09:34 PM
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
--------------------
[Quoted Text]
>From: "Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk>
>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
<OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
<03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/9/2007 6:43:07 PM
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[ at ]discussions.microsoft.com> wrote in message
news:uzNvYDsqHHA.4280[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
> 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?
Theo <theo[ at ]discussions.microsoft.com> 6/9/2007 7:02:30 PM
Yes. XP 5.1 is XP-32 bit and XP 5.2 is XP-64 bit.


Tony Sperling wrote:
[Quoted Text]
> 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[ at ]discussions.microsoft.com> wrote in message
> news:uzNvYDsqHHA.4280[ at ]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?
"Homer J. Simpson" <root[ at ]127.0.0.1> 6/9/2007 7:31:57 PM
[Quoted Text]
> 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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/9/2007 9:33:15 PM
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[ at ]127.0.0.1> wrote in message
news:%23IMbizsqHHA.3248[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
>> 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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/9/2007 9:35:12 PM
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[ at ]discussions.microsoft.com> wrote in message
news:O3HI$isqHHA.500[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> 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[ at ]discussions.microsoft.com> wrote in message
>> news:uzNvYDsqHHA.4280[ at ]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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/9/2007 9:35:23 PM
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[ at ]online.microsoft.com> wrote in message
news:xesZbFsqHHA.1032[ at ]TK2MSFTNGHUB02.phx.gbl...
[Quoted Text]
> 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[ at ]dbREMOVEmail.dk>
>>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
> <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
> <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/9/2007 11:13:19 PM


(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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/10/2007 12:13:55 AM
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[ at ]online.microsoft.com> wrote in message
news:xesZbFsqHHA.1032[ at ]TK2MSFTNGHUB02.phx.gbl...
[Quoted Text]
> 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[ at ]dbREMOVEmail.dk>
>>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
> <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
> <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/10/2007 10:57:55 AM
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[ at ]mvKILLALLSPAMMERSps.org> wrote in message
news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47[ at ]microsoft.com...
[Quoted Text]
> 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[ at ]online.microsoft.com> wrote in message
> news:xesZbFsqHHA.1032[ at ]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[ at ]dbREMOVEmail.dk>
> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
> > <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/10/2007 3:12:58 PM
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[ at ]dbREMOVEmail.dk> wrote in message
news:urMyy40qHHA.4100[ at ]TK2MSFTNGP06.phx.gbl...
[Quoted Text]
>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[ at ]mvKILLALLSPAMMERSps.org> wrote in message
> news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47[ at ]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[ at ]online.microsoft.com> wrote in message
>> news:xesZbFsqHHA.1032[ at ]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[ at ]dbREMOVEmail.dk>
>> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
>> > <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
>> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/10/2007 5:23:44 PM
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[ at ]dbREMOVEmail.dk> wrote in message
news:ebfJWvuqHHA.1172[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
>
>
> (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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/11/2007 1:15:11 AM
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" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in message
news:A456FC0B-5279-446F-958C-7C8D762CA61F[ at ]microsoft.com...
[Quoted Text]
> 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[ at ]dbREMOVEmail.dk> wrote in message
> news:urMyy40qHHA.4100[ at ]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[ at ]mvKILLALLSPAMMERSps.org> wrote in
message
> > news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47[ at ]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[ at ]online.microsoft.com> wrote in
message
> >> news:xesZbFsqHHA.1032[ at ]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[ at ]dbREMOVEmail.dk>
> >> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
> >> > <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
> >> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/11/2007 5:17:50 AM
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" <tony.sperling[ at ]dbREMOVEmail.dk> wrote in message
news:Otdz0X8qHHA.192[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> 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" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in message
> news:A456FC0B-5279-446F-958C-7C8D762CA61F[ at ]microsoft.com...
>> 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[ at ]dbREMOVEmail.dk> wrote in message
>> news:urMyy40qHHA.4100[ at ]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[ at ]mvKILLALLSPAMMERSps.org> wrote in
> message
>> > news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47[ at ]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[ at ]online.microsoft.com> wrote in
> message
>> >> news:xesZbFsqHHA.1032[ at ]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[ at ]dbREMOVEmail.dk>
>> >> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
>> >> > <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
>> >> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
"Tony Sperling" <tony.sperling[ at ]dbREMOVEmail.dk> 6/11/2007 10:22:58 PM
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" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in message
news:C236B921-2627-4F7D-92DF-4E67C4843847[ at ]microsoft.com...
[Quoted Text]
> 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" <tony.sperling[ at ]dbREMOVEmail.dk> wrote in message
> news:Otdz0X8qHHA.192[ at ]TK2MSFTNGP02.phx.gbl...
> > 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" <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote in
message
> > news:A456FC0B-5279-446F-958C-7C8D762CA61F[ at ]microsoft.com...
> >> 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[ at ]dbREMOVEmail.dk> wrote in message
> >> news:urMyy40qHHA.4100[ at ]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[ at ]mvKILLALLSPAMMERSps.org> wrote in
> > message
> >> > news:2A7CFBA5-DCFB-4F88-ACCA-BDC912E3DF47[ at ]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[ at ]online.microsoft.com> wrote in
> > message
> >> >> news:xesZbFsqHHA.1032[ at ]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[ at ]dbREMOVEmail.dk>
> >> >> >>References: <634609FA-0B4B-4ECA-84A4-C9C2583F6433[ at ]microsoft.com>
> >> >> > <OEHs3HoqHHA.192[ at ]TK2MSFTNGP02.phx.gbl>
> >> >> > <03169ABE-7A8B-4741-A461-BCFE4F2FEAF5[ at ]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[ at ]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?
Josh Hillman <hillman[ at ]talstar.com> 6/12/2007 12:01:53 AM
I know nothing about PowerShell, but there's an easy way of directly
obtaining the information via WMI without having to do any kind of
build number comparisons, etc.:
WMI Tasks: Operating Systems
http://msdn2.microsoft.com/en-US/library/aa394596.aspx

Here's an example using VBScript and WMI to determine the OS version
as well as service pack version (if any):

Dim strComputer, objWMIService, colOperatingSystems, OS
strComputer = "."
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
OS = objOperatingSystem.Caption & " " _
& objOperatingSystem.Version
If objOperatingSystem.ServicePackMajorVersion > 0 Then
OS = OS & " Service Pack " _
& objOperatingSystem.ServicePackMajorVersion & "." _
& objOperatingSystem.ServicePackMinorVersion
End If
WScript.Echo OS
Next
Set colOperatingSystems = Nothing
Set objWMIService = Nothing

Results (from my own computer):
C:\Temp>cscript /nologo windowsversion.vbs
Microsoft(R) Windows(R) XP Professional x64 Edition 5.2.3790 Service
Pack 2.0

Josh

On Fri, 8 Jun 2007 17:56:05 -0700, "Charlie Russel - MVP"
<charlie[ at ]mvKILLALLSPAMMERSps.org> wrote:

[Quoted Text]
>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.
Re: Best Way to get version from registry?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/12/2007 5:46:19 AM
Interesting. Reminds me why I don't speak Basic. ;) Though goodness knows
WMI is almost as annoying in PowerShell. But thanks, I actually hadn't
thought of going after it using WMI - that's an interesting way to do it,
and might make sense for some purposes.

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


"Josh Hillman" <hillman[ at ]talstar.com> wrote in message
news:4nnr63pq7cko6ob8qs9gq9l95sf7g8lo4v[ at ]4ax.com...
[Quoted Text]
>I know nothing about PowerShell, but there's an easy way of directly
> obtaining the information via WMI without having to do any kind of
> build number comparisons, etc.:
> WMI Tasks: Operating Systems
> http://msdn2.microsoft.com/en-US/library/aa394596.aspx
>
> Here's an example using VBScript and WMI to determine the OS version
> as well as service pack version (if any):
>
> Dim strComputer, objWMIService, colOperatingSystems, OS
> strComputer = "."
> Set objWMIService =
> GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery _
> ("Select * from Win32_OperatingSystem")
> For Each objOperatingSystem in colOperatingSystems
> OS = objOperatingSystem.Caption & " " _
> & objOperatingSystem.Version
> If objOperatingSystem.ServicePackMajorVersion > 0 Then
> OS = OS & " Service Pack " _
> & objOperatingSystem.ServicePackMajorVersion & "." _
> & objOperatingSystem.ServicePackMinorVersion
> End If
> WScript.Echo OS
> Next
> Set colOperatingSystems = Nothing
> Set objWMIService = Nothing
>
> Results (from my own computer):
> C:\Temp>cscript /nologo windowsversion.vbs
> Microsoft(R) Windows(R) XP Professional x64 Edition 5.2.3790 Service
> Pack 2.0
>
> Josh
>
> On Fri, 8 Jun 2007 17:56:05 -0700, "Charlie Russel - MVP"
> <charlie[ at ]mvKILLALLSPAMMERSps.org> wrote:
>
>>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.

Re: Best Way to get version from registry?
"Homer J. Simpson" <root[ at ]127.0.0.1> 6/12/2007 1:28:22 PM
[Quoted Text]
> Interesting. Reminds me why I don't speak Basic. ;) Though goodness knows
> WMI is almost as annoying in PowerShell.

WMI just exposes scriptable objects, so the fact that Josh's script was in
VBScript shouldn't be a stumbling block. Doesn't PowerShell use .NET? I'm
pretty sure .NET itself wraps WMI in some class somewhere...


Re: Best Way to get version from registry?
"Charlie Russel - MVP" <charlie[ at ]mvKILLALLSPAMMERSps.org> 6/12/2007 8:37:25 PM
Oh, PS definitely does WMI. Which was why I said that going after the
information via WMI was interesting- I hadn't thought of that approach.

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


"Homer J. Simpson" <root[ at ]127.0.0.1> wrote in message
news:%23$$qFXPrHHA.3456[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
>> Interesting. Reminds me why I don't speak Basic. ;) Though goodness knows
>> WMI is almost as annoying in PowerShell.
>
> WMI just exposes scriptable objects, so the fact that Josh's script was in
> VBScript shouldn't be a stumbling block. Doesn't PowerShell use .NET?
> I'm pretty sure .NET itself wraps WMI in some class somewhere...
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen