可以和winmgmts的查询页面对应

from win32com.client import GetObject
import pywintypes result=[]
def enum_namespace(name):
try:
wmi = GetObject('winmgmts:/' + name)
namespaces = wmi.InstancesOf('__Namespace')
for namespace in namespaces:
enum_namespace('{name}/{subname}'.format(name=name,
subname=namespace.Name))
except pywintypes.com_error:
print(name, 'limit of authority')
else:
result.append(name) enum_namespace('root')
print result

  

04-26 17:25