[python-win32] Dispatching something that requires elevation
Simon McConnell
simonmcconnell at gmail.com
Sat Jun 9 01:11:27 EDT 2018
Hi,
I am trying to dispatch a COM interface of a program that is set to "Run as
Administrator" in the Compatibility Settings of its properties. Running
the script w/o elevation results in a 'requires elevation' error. Running
the script with elevation results in a 'server execution failed' error,
which I understand to be "I can't find that thing". Removing the "Run as
Administrator" from the Compatibility settings and running the script w/o
elevation works, but unfortunately, this program needs to be run as
administrator. When opening the program manually I have to accept the UAC
popup and cannot turn it off thanks to Group Policy. Any clues?
import win32com.client
o = win32com.client.Dispatch("CimplicityME.Application")
gives the error:
Traceback (most recent call last):
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\smcconnell\PycharmProjects\proficy\src\proficy.py", line
5, in <module>
o = win32com.client.Dispatch("CimplicityME.Application")
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147024156, 'The requested operation requires
elevation.', None, None)
If I run the script as administrator I get the following error:
Traceback (most recent call last):
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\smcconnell\PycharmProjects\proficy\src\proficy.py", line
5, in <module>
o = win32com.client.Dispatch("CimplicityME.Application")
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File
"C:\Users\smcconnell\PycharmProjects\proficy\venv\lib\site-packages\win32com\client\dynamic.py",
line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20180609/ebbcb1de/attachment.html>
More information about the python-win32
mailing list