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.