Jump to content


  • 0
sweety_devil

How to activate windows automatically

Question

3 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.