Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Bulk change the Operating system serial no (Os Product key).Vbs/Excel macro.

Hi,

Bulk change the Operating system serial no (Os Product key).Vbs/Excel macro.
can anyone help with a code that can change all the machines in a txt file or excel colum A with a different Product key.

REgards
Sharath
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

If I am understanding what you are asking, I don't think this can be done at all.

Let's see if some other Experts have more input...

JeffCoachman
Hi, check out the scripts on this page, under "Method 2":
How to change the Volume Licensing product key on a computer that is running Windows XP Service Pack 1 and later versions of Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q328874

I have never used them, but I know that version of the Magic Jelly Bean tool 1.51 and older used this code to change the license key.  Use the ChangeVLKeySP1.vbs if you're running Windows XP SP1 or later.

Regards,

Rob.
Avatar of bsharath

ASKER

Rob any ways to change on a lot of systems in one show.

I have the names and serial no's in the excel. If the script can check colum Q for machine names and if OS win xp change the serial no to whats there in colum "BW"
OK, I would advise you to test this in a new workbook, with just one PC in column Q (starting at row 2), and one License Key in column BW.

Regards,

Rob.
Sub Change_WindowsXP_SP1_Key()
 
    Const HKLM = &H80000002
    Dim VOL_PROD_KEY
    
    For intRow = 2 To Cells(65536, "Q").End(xlUp).Row
        strComputer = Trim(Cells(intRow, "Q").Value)
        If strComputer <> "" Then
            If Ping(strComputer) = True Then
                Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
                Set colItems = objWMIService.ExecQuery("Select Caption,ServicePackMajorVersion from Win32_OperatingSystem", , 48)
                For Each objItem In colItems
                     strCaption = objItem.Caption
                     strSPMajor = objItem.ServicePackMajorVersion
                Next
                
                VOL_PROD_KEY = Trim(Cells(intRow, "BW").Value)
                VOL_PROD_KEY = Replace(VOL_PROD_KEY, "-", "") 'remove hyphens if any
            
                If InStr(strCaption, "XP Professional") > 0 And CInt(strSPMajor) >= 1 Then
                    On Error Resume Next
                    For Each objProduct In GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer).InstancesOf("win32_WindowsProductActivation")
                        result = objProduct.SetProductKey(VOL_PROD_KEY)
                        If Err <> 0 Then
                            MsgBox Err.Description & vbCrLf & "0x" & Hex(Err.Number)
                            Err.Clear
                        End If
                    Next
                    On Error GoTo 0
                    
                ElseIf InStr(strCaption, "XP Professional") > 0 Then
                    Set objReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:stdRegProv")
                    On Error Resume Next
                    objReg.DeleteValue HKLM, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents", "OOBETimer" 'delete OOBETimer registry value
                    Err.Clear
                    For Each Obj In GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("win32_WindowsProductActivation")
                       result = Obj.SetProductKey(VOL_PROD_KEY)
                       If Err <> 0 Then
                          MsgBox Err.Description & vbCrLf & "0x" & Hex(Err.Number)
                          Err.Clear
                       End If
                    Next
                    On Error GoTo 0
                End If
            End If
        End If
    Next
 
End Sub
 
Function Ping(strComputer)
    Dim objShell, boolCode
    Set objShell = CreateObject("WScript.Shell")
    boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
    If boolCode = 0 Then
        Ping = True
    Else
        Ping = False
    End If
End Function

Open in new window

Ron i get this

---------------------------
Microsoft Excel
---------------------------
Generic failure

0x80041001
---------------------------
OK  
---------------------------

I will have systems mainly with Win Xp sp2 and Sp3 will that be an issue
Ron i get this

---------------------------
Microsoft Excel
---------------------------
Generic failure

0x80041001
---------------------------
OK  
---------------------------

I will have systems mainly with Win Xp sp2 and Sp3 will that be an issue
Are you running the Excel spreadsheet as a user who has full admin rights over the remote machine?  You will need these rights to change such keys....

Rob.
Yes i am running from a Domain Admin permission
Which line is the error on?
It does not take me to the code... I get this popup and continues
It does not take me to the code... I get this popup and continues
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get this

---------------------------
Microsoft Excel
---------------------------
Product ID for Dev515: 76487-640-1068332-23346

Windows XP Professional SP1 or greater.
---------------------------
OK  
---------------------------
I get this

---------------------------
Microsoft Excel
---------------------------
Product ID for Dev515: 76487-640-1068332-23346

Windows XP Professional SP1 or greater.
---------------------------
OK  
---------------------------
Hmmm, so if you uncomment lines 24 through 28 above:
                        'result = objProduct.SetProductKey(VOL_PROD_KEY)
                        'If Err <> 0 Then
                        '    MsgBox Err.Description & vbCrLf & "0x" & Hex(Err.Number)
                        '    Err.Clear
                        'End If


and run it again, does it work?  Are you sure you have a valid license key in column BW?

Regards,

Rob.
I did the change but still does not update the serial no
Serial no is correct and machine live.

Running it from a machine where i have powers on the remote machine
I have just read that this method cannot be used with OEM versions of Windows XP, because this method is only valid if the ActivationRequired property is equal to 1, and OEM keys do not require activation.

This gives you some more info, but if you're trying to use keys that don't require activation, you're out of luck on this one.
http://technet.microsoft.com/en-us/library/bb457096.aspx

Regards,

Rob.
:-(

Would there be no workaround Rob... If not through Excel...Some tool that can be used for bulk change?
With some code
:-(

Would there be no workaround Rob... If not through Excel...Some tool that can be used for bulk change?
With some code
I'd be surprised if there was.....you might try the Magic Jelly Bean Keyfinder tool. Make sure you get version 1.51 from 08.6.2006

Then run it manually on a machine and see if it lets you change the key to one you want.

If that doesn't work, you won't be able to without violating the Activation of the workstation, I don't think.

Regards,

Rob.
Rob i did run this

 Magic Jelly Bean Keyfinder tool. version 1.51 from 08.6.2006
But there is no option to change.
I am able to view only
Rob i did run this

 Magic Jelly Bean Keyfinder tool. version 1.51 from 08.6.2006
But there is no option to change.
I am able to view only
When I use that, I have this option.

If you don't have this option, then I don't think it is possible to change your keys.

Regards,

Rob.
KeyFinder151.jpg
Rob change windows key is disabled for me in all machines that i tried...
Rob change windows key is disabled for me in all machines that i tried...
Hmmm, in that case you must have Windows Keys that cannot be changed, most likely because they would have been pre-activated by your manufacturer.  I am not aware of any other way to change the Windows key.

Rob.
Hi Rob can you see this link...

Will this help with this Q...
http://desktopsuport.blogspot.com/2009/07/how-to-change-volume-licensing-product.html