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