I am trying to use the SetProductKey method of Win32_WindowsProductActivation to set the windows xp key for a custom need of mine as per the second Microsoft vbs script here :http://support.microsoft.com/kb/328874. No matter what method i use i always get shut down. I have tried wmi:
import wmi
c = wmi.WMI()
c.Win32_WindowsProductActivation.SetProductKey('XXXXXXXXXXXXXXXXXXXX')
This is what i get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python\lib\site-packages\wmi.py", line 427, in __call__
handle_com_error ()
File "C:\Program Files\Python\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147352567, 'Exception occurred.', (0,u'SWbemObjectEx', u'Invalid Method Parameter(s) ', None, 0, -2147217361), None)
Its the same error i get with any other method i try like :
from win32com.client import GetObject
WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!//.rootcimv2").InstancesOf("Win32_WindowsProductActivation")
for User in WMIService:
User.SetProductKey('XXXXXXXXXXXXXXXXXXXXXXXXX')
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 501, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'SWbemObjectEx', u'Invalid method Parameter(s) ', None, 0, -2147217361), None)
The product key is valid, i have tried with and without dashes, and the ActivationRequired attribute is set to one as per the documentation here : http://msdn.microsoft.com/en-us/library/aa393588%28v=VS.85%29.aspx
Any help is greatly appreciated. Any python - windows COM gurus here, please give a hand. I have little to no experience in COM and it is all a big mess in my head. Even some pointers as to where to look, although i have practically looked everywhere already, would be very welcome.