0

I have installed WMI for python and pywin32 extensions to be able to use win32 apis from my python scripts. While I can get all the info from other clasees like Win32_Battery, Win32_Processor I am having tough time with Win32_Tpm class.

I want to use Win32_Tpm module in python to play around with various tpm features, but all my references to win32_tpm are returning null.

Has anybody been able to use the same without any problems. Any help would be appreciated very much.

My code is simple:

import wmi,sys,os

c = wmi.WMI()

for tpm in c.Win32_Tpm():
    pass

if tpm.IsActivated():
    print 'Version %s' %(tpm.SpecVersion)
    print 'Physical presence %s' %(tpm.PhysicalPresenceVersionInfo)

1 Answers1

0

Thanks to Tim Golden. I found the answer.

Please refer to the thread

http://mail.python.org/pipermail/python-win32/2012-June/012381.html

If the above link is not accessible here is what we need to do, since Win32_Tpm() belongs to separate namespace we need to specify the full path of the namespace. Hope this helps.

import os
import wmi
import win32api
import _winreg

c = wmi.WMI(namespace="root/cimv2/security/microsofttpm")
for t in c.Win32_Tpm():
  pass

print t.IsActivated()

if t.IsActivated():
  print 'Activated %s' %(t.IsActivated_InitialValue)
  print 'Enabled %s' %(t.IsEnabled_InitialValue)
  print 'Owned %s' %(t.IsOwned_InitialValue)
  print 'Version %s' %(t.SpecVersion)
  print 'Manufaturer %s' % (t.ManufacturerVersion)
  print 'Manufaturer %s' % (t.ManufacturerVersionInfo) 
  print 'Physical presence %s' %(t.PhysicalPresenceVersionInfo)
  print 'prashant'