[python-win32] Access Denied

Tim Roberts timr at probo.com
Sun Jan 24 02:44:23 EST 2016


On Jan 21, 2016, at 9:27 AM, Srinivasa, Vish <Vish.Srinivasa at elavon.com<mailto:Vish.Srinivasa at elavon.com>> wrote:

           This is about a process that runs as a Windows 7 service. It is a python executable that I am trying to run as a service and when it is executed from the commandline it runs fine. However when it runs as a local account (which is the same user as the user that runs it from commandline) it fails with the following error:-

                                                      (<class 'pywintypes.com<http://pywintypes.com/>_error'>, com_error(-2147024891, 'Access is denied.', None, None)

The line where it fails is the following:-

                                                   MyConn = win32com.client.gencache.EnsureDispatch("Outlook.Application").GetNamespace("MAPI”)

For security reasons, services in Windows run in what is called “session 0”, which is prohibited from connecting with the desktop.  The Outlook application is a GUI application, so it cannot run in session 0.

There are a couple of alternatives.  You can modify the service configuration to allow it to interact with the desktop, or you can connect with MAPI without going through Outlook.

https://msdn.microsoft.com/en-us/library/office/cc839856.aspx
—
Tim Roberts, timr at probo.com<mailto:timr at probo.com>
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20160123/ee24267e/attachment.html>


More information about the python-win32 mailing list