I am trying to control my device manager programmatic through python (ie disable and re-enabling devices). However I am having trouble figuring out what are the attributes in the namespace of the "win32com.client.Dispatch("Shell.Application")". All i know how to do is get the name and print it. I did a debugging run through the code but i couldn't find anything useful.
Here is what I have so far
import win32com.client
shell = win32com.client.Dispatch("Shell.Application")
control_panel = shell.Namespace(3)
for item in control_panel.Items():
if item.Name == "Device Manager":
print item
break
this wasn't very useful either:
control_panel.GetNamespace("MAPI")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: <unknown>.GetNamespace
One way to check the attributes in a COM object is using the combrowse.py
available on win32com\client
in your python site-packages folder
Just run the script (double clicking or from command line/python) and a window should appear with all the available com objects. Under Registered Type Libraries
you should find the Shell under the correspondent Library in Microsoft Shell Controls And Automation
You can check this with the following command in python:
from win32com.client import gencache
shell = gencache.EnsureDispatch('Shell.Application')
print shell
Also, using the gencache
method, you can use Tab
to check some of the available methods, but for a comprehensive list check the combrowse.py
. The only issue is that some of the methods listed at the combrowse.py
are not really available within python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With