Skip to content

How to activate windows automatically

Featured Replies

Hi,

 

I created a wim file to deploy XP SP3.

 

It's working fine but I installed a OEM version and I need to activate each time I deploy.

 

Is there a solution to auto activate each installation from sccm?

 

Thank you.

  • 3 weeks later...

activexp.vbs

 


'***************************************************************
'***************************************************************

ON ERROR RESUME NEXT
productKey = "PXRQ3-7VPMV-CQWXR-8Y4KX-RD786"

'blocked genericPK = "PXRQ3-7VPMV-CQWXR-8Y4KX-RD786"
const seqNumber = "010-053298"
           'part of PID, derived from genericPK
actvProxyServer = "<insert proxy data>"         'replace with values appropriate
actvProxyPort   = "<insert proxy data>"         'to the customer environment
For Each wpaObj In GetObject("winmgmts:{impersonationLevel=impersonate}").
     InstancesOf ("win32_WindowsProductActivation")
     'Set new Product Key if the current PID's
     'Sequence Number matches the global PID (once only)
     If Mid(wpaObj.ProductID, 7, 10) = seqNumber Then
           WScript.Echo "Sequence Numbers match!"
           'Sequence Numbers match: get new Product Key from database
           'Get new Product Key from database"
           productKey = GetProductKey()
           WScript.Echo "Product Key: " & productKey
           'Set new Product Key
           result = wpaObj.SetProductKey(productKey)
           WScript.Echo "SetProductKey() returned = " & result
           If err <> 0 Then
                 WScript.Echo Err.Description, "0x" & Hex(Err.Number)
                 Halt
     End If
  End If         ' ProductKey check/set
  'If not yet activated, set proxy and activate the machine
  If wpaObj.ActivationRequired <> 0 Then
           serverName = wpaObj.ServerName
           WScript.Echo "ActivationRequired for " & serverName
           'Set proxy. First save existing proxy for later
           For Each proxyObj In
                 GetObject("winmgmts:{impersonationLevel=impersonate}").
                 InstancesOf ("win32_Proxy")
                 savedProxyServer = proxyObj.ProxyServer
                 savedProxyPort   = proxyObj.ProxyPortNumber
                 WScript.Echo "Saved Proxy: " & savedProxyServer &
                 ":" & savedProxyPort
           Next
           'Set temporary activation proxy
           For Each proxyObj In
                 GetObject("winmgmts:{impersonationLevel=impersonate}").
                 InstancesOf ("win32_Proxy")
                 result = proxyObj.SetProxySetting(actvProxyServer,actvProxyPort)
                 WScript.Echo "SetProxySetting() returned = " & result
                 If err <> 0 Then
                       WScript.Echo Err.Description,"0x" & Hex(Err.Number)
                       Halt
                 End If
           Next
           'Activate Machine
           result = wpaObj.ActivateOnline()
           WScript.Echo "ActivateOnline Method() returned = "& result
           If err <> 0 Then
                WScript.Echo Err.Description, "0x" & Hex(Err.Number)
                ' do not halt - need to reset proxy
       End If
       'Restore proxy to original setting
       For Each proxyObj In
             GetObject("winmgmts:{impersonationLevel=impersonate}").
             InstancesOf ("win32_Proxy")
             result = proxyObj.SetProxySetting (savedProxyServer,savedProxyPort)
             WScript.Echo "SetProxySetting Method() = " & result
             If err <> 0 Then
                       WScript.Echo Err.Description, "0x"& Hex(Err.Number)
                       Halt
                  End If
           Next
     End If
Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.