Does anyone have a vbScript to pull out the product key of a Win2k or Win2k3
server?

Thanks,
Troy

Re: Pull product key by Ron

Ron
Sun Oct 10 09:13:55 CDT 2004

Here you go,

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

Option Explicit

Set ws = WScript.CreateObject("WScript.Shell")
Dim ws, t, p1, p2, n, cn, vbdefaultbutton
Dim itemtype

p1 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\"

n = ws.RegRead(p1 & "ProductId")
t = "Read Your Product ID"
cn = InputBox("This is your Product ID Number", t, n)
If cn <> "" Then
ws.RegWrite p1 & "ProductId", cn
End If

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

"Troy Bruder" <N0-Spam-troy.bruder@aptconsulting.com> wrote in message
news:uzn4uhTrEHA.192@tk2msftngp13.phx.gbl...
> Does anyone have a vbScript to pull out the product key of a Win2k or
Win2k3
> server?
>
> Thanks,
> Troy
>
>



Re: Pull product key by mayayana

mayayana
Sun Oct 10 11:41:25 CDT 2004

Not sure about Win2K but this info. might help you work it out:

In Win9x the key
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\
has the following values -

ProductKey - the CD key used during install.
(The 5 sets of 5 characters. Used after Win95.)

ProductID - Apparently a manufacturing ID that designates
the specific version details. For instance, pre-installed Windows
will usually have "OEM" in the ProductID, while a full version
CD install will not. ProductID was used as the CD key in Win95
but I don't think it's been used for that since then.

--
--
Troy Bruder <N0-Spam-troy.bruder@aptconsulting.com> wrote in message
news:uzn4uhTrEHA.192@tk2msftngp13.phx.gbl...
> Does anyone have a vbScript to pull out the product key of a Win2k or
Win2k3
> server?
>
> Thanks,
> Troy
>
>



Re: Pull product key by McKirahan

McKirahan
Sun Oct 10 11:50:23 CDT 2004

"Ron Casey" <tasselhoff@thisisnotreal.com> wrote in message
news:eV2vqNtrEHA.2776@TK2MSFTNGP14.phx.gbl...
> Here you go,
>
> --------------------------------------------------------------------------
--
> ---------
>
> Option Explicit
>
> Set ws = WScript.CreateObject("WScript.Shell")
> Dim ws, t, p1, p2, n, cn, vbdefaultbutton
> Dim itemtype
>
> p1 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\"
>
> n = ws.RegRead(p1 & "ProductId")
> t = "Read Your Product ID"
> cn = InputBox("This is your Product ID Number", t, n)
> If cn <> "" Then
> ws.RegWrite p1 & "ProductId", cn
> End If
>
> --------------------------------------------------------------------------
-

[snip -- please do not top post]

Not sure why "p2", "vbdefaultbutton", and "itemtype" were declared;
or why "ws" was set before it was declared;
or why "RegWrite" was used -- doesn't this change the Registry?.

Here's a variation on Ron Casey's solution:

Option Explicit
Const cREG = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId"
Dim objWSS
Set objWSS = WScript.CreateObject("WScript.Shell")
WScript.Echo objWSS.RegRead(cREG)
Set objWSS = Nothing

P.S. I only tested this on Win98SE.