Re: [python-win32] Dispatching something that requires elevation

2018-06-09 Thread Tim Roberts
On Jun 8, 2018, at 10:11 PM, Simon McConnell  wrote:
> 
> 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". 

No, actually.  That's 0x80080005, which is a DCOM "access denied" error.  Are 
you quite sure this account has the privileges needed to run this software?


> 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.

So, are you saying you don't need elevation to call this server, you only need 
it for other parts?  Can you spawn the COM access into a separate process?
— 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Dispatching something that requires elevation

2018-06-09 Thread Vernon D. Cole
look in github.com/salt-bevy/sudo.py

for a module which will request elevated privileges for a Python script
running as a normal user.
Perhaps that can help create a solution for your use case.

There is a sample call for it in bootstrap_bevy_member_here.py or you can
just run it from the command line with the script you want to run as
administrator as its arguments.



On Fri, Jun 8, 2018 at 11:11 PM, Simon McConnell 
wrote:

> 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 
> 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 
> 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)
>
>
> ___
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Dispatching something that requires elevation

2018-06-09 Thread Simon McConnell
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 
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 
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)
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32