From ckkart at hoc.net Sun Jun 3 11:51:14 2018 From: ckkart at hoc.net (ckkart at hoc.net) Date: Sun, 03 Jun 2018 12:51:14 -0300 Subject: [python-win32] get MAPI session from OOM In-Reply-To: <998602D6-E89E-465C-A920-9532812666E4@probo.com> References: <02767fc83c6dcac273a7e424d354f92c@www.hoc.net> <7A4B40C2-4041-4F9D-94B8-2A4569D70B24@probo.com> <0f4846a15f08ccddcd3d8f4ffdfa78bc@www.hoc.net> <998602D6-E89E-465C-A920-9532812666E4@probo.com> Message-ID: <7a34a7fa9e8f0c46b24787bc0948ef99@www.hoc.net> Am 2018-05-31 03:31, schrieb timr at probo.com: > On May 30, 2018, at 11:23 AM, ckkart at hoc.net wrote: >> >> >> Any ideas? Do you think it will help to do a fresh install of office >> 2016? > > In addition to just installing Outlook, have you configured Outlook? > You can't access MAPI unless you have incoming and outgoing servers > configured and authenticated. I installed Office 2016 from scratch and still get the same error. But I could make a new observation. When running a standalone script from win32com.client import Dispatch o = Dispatch('Outlook.Application') o.GetNamespace('MAPI').Session.MAPIOBJECT.QueryInterface(mapi.IID_IMAPISession) a window opens saying that there is no standard mail application defined. I checked in the system settings and changed the setting from the windows 10 mail app to outlook but I still get that error. I get it too when I initialize a MAPISession like this: from win32com.mapi import mapi mapi.MAPIInitialize((0,mapi.MAPI_MULTITHREAD_NOTIFICATIONS)) I am lost. Christian From ahz001 at gmail.com Sun Jun 3 18:30:59 2018 From: ahz001 at gmail.com (Andrew Ziem) Date: Sun, 3 Jun 2018 16:30:59 -0600 Subject: [python-win32] large buffer with GetOpenFileNameW In-Reply-To: <4aaff24c-9bc5-56c5-6078-b2b79043bacc@probo.com> References: <4aaff24c-9bc5-56c5-6078-b2b79043bacc@probo.com> Message-ID: Yes, that worked to increase the buffer. Thank you, Tim. :) Andrew On Thu, May 24, 2018 at 12:10 PM, Tim Roberts wrote: > Andrew Ziem wrote: >> When I select a few files, the dialog works, but when I select many >> files, I get the following error. Do you have any advice? >> >> error: (12291, 'GetOpenFileNameW', 'No error message is available') >> >> Error 12291 is FNERR_BUFFERTOOSMALL > > Yes. The code in win32gui.i only allocates a buffer of 1,024 > characters. If you select more than that, you'll get FNERR_BUFFERTOOSMALL. > > There may be a slimy way to work around this. The code allocates the > larger of 1024 characters or the size of the File parameter. You could > try something like > win32gui.GetOpenFileName( None, File='\x00' * 2048, Flags=... ) > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 From ckkart at hoc.net Mon Jun 4 22:00:11 2018 From: ckkart at hoc.net (ckkart at hoc.net) Date: Mon, 4 Jun 2018 23:00:11 -0300 Subject: [python-win32] get MAPI session from OOM In-Reply-To: <7a34a7fa9e8f0c46b24787bc0948ef99@www.hoc.net> References: <02767fc83c6dcac273a7e424d354f92c@www.hoc.net> <7A4B40C2-4041-4F9D-94B8-2A4569D70B24@probo.com> <0f4846a15f08ccddcd3d8f4ffdfa78bc@www.hoc.net> <998602D6-E89E-465C-A920-9532812666E4@probo.com> <7a34a7fa9e8f0c46b24787bc0948ef99@www.hoc.net> Message-ID: <59057e2f-085d-6c86-ce26-b40620731c98@hoc.net> Am 03/06/18 um 12:51 schrieb Christian K.: > Am 2018-05-31 03:31, schrieb timr at probo.com: >> On May 30, 2018, at 11:23 AM, ckkart at hoc.net wrote: >>> >>> >>> Any ideas? Do you think it will help to do a fresh install of office >>> 2016? >> >> In addition to just installing Outlook, have you configured Outlook? >> You can't access MAPI unless you have incoming and outgoing servers >> configured and authenticated. > > I installed Office 2016 from scratch and still get the same error. But I > could make a new observation. When running a standalone script > > from win32com.client import Dispatch > o = Dispatch('Outlook.Application') > o.GetNamespace('MAPI').Session.MAPIOBJECT.QueryInterface(mapi.IID_IMAPISession) > > > a window opens saying that there is no standard mail application > defined. I checked in the system settings and changed the setting from > the windows 10 mail app to outlook but I still get that error. I get it > too when I initialize a MAPISession like this: > > from win32com.mapi import mapi > mapi.MAPIInitialize((0,mapi.MAPI_MULTITHREAD_NOTIFICATIONS)) > I got it. This was due to a very stupid mistake. I tried to connect to 32 bit office from 64 bit python. Sorry for the noise. Christian From simonmcconnell at gmail.com Sat Jun 9 01:11:27 2018 From: simonmcconnell at gmail.com (Simon McConnell) Date: Sat, 9 Jun 2018 07:11:27 +0200 Subject: [python-win32] Dispatching something that requires elevation Message-ID: 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) -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sat Jun 9 12:52:12 2018 From: vernondcole at gmail.com (Vernon D. Cole) Date: Sat, 9 Jun 2018 10:52:12 -0600 Subject: [python-win32] Dispatching something that requires elevation In-Reply-To: References: Message-ID: 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 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Jun 9 21:48:28 2018 From: timr at probo.com (Tim Roberts) Date: Sat, 9 Jun 2018 18:48:28 -0700 Subject: [python-win32] Dispatching something that requires elevation In-Reply-To: References: Message-ID: 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, timr at probo.com Providenza & Boekelheide, Inc. From simonmcconnell at gmail.com Sat Jun 9 21:48:53 2018 From: simonmcconnell at gmail.com (Simon McConnell) Date: Sun, 10 Jun 2018 03:48:53 +0200 Subject: [python-win32] Dispatching something that requires elevation In-Reply-To: References: Message-ID: Thanks for the reply. I have tried running the python script as admin. When I do run as admin, I get the following error: pywintypes.com_error: (-2146959355 <(214)%20695-9355>, 'Server execution failed', None, None). I've noticed, by watching Task Manager, that the application opens and closes a couple of seconds later. Event Viewer shows a DistributedCOM 10010 Error for each failed attempt: The server {FDE63972-78D6-4144-B2E0-28960C67B33D} did not register with DCOM within the required timeout. Tried it on another PC and it works fine and doesn't require elevation to admin. Must be something borked with my Windows. Ta, Simon On Sun, 10 Jun 2018 at 02:52 Vernon D. Cole wrote: > 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 <(214)%20722-1021>, '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 <(214)%20702-4156>, '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 <(214)%20722-1021>, '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 <(214)%20695-9355>, 'Server execution >> failed', None, None) >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simonmcconnell at gmail.com Sun Jun 10 20:20:06 2018 From: simonmcconnell at gmail.com (Simon McConnell) Date: Mon, 11 Jun 2018 02:20:06 +0200 Subject: [python-win32] Dispatching something that requires elevation In-Reply-To: References: Message-ID: Sorry, I'm not sure what you mean by spawn the COM access in a separate process. This is my first time dabbling with COM objects. I use the software every day in the traditional fashion so I know I have access. It looks like it spawns another process "System Login State Manager" which seems to be the determinant of whether DCOM access is allowed/denied. I've noticed two instances of this running sometimes and sometimes none. I think most of the issues were self-induced from spawning the process from python, it failing and me killing too many or not enough of the tasks in task manager. Is there a neat way to kill all the tasks that you've started when your script fails without hitting the application's Quit call? I am currently wrapping it in a fx = win32com.client.Dispatch('CimplicityME.Application') try: # do stuff except: fx.Quit() On Mon, 11 Jun 2018 at 02:00 wrote:Date: Sat, 9 Jun 2018 18:48:28 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] Dispatching something that requires > elevation > Message-ID: > Content-Type: text/plain; charset=utf-8 > > 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, timr at probo.com > Providenza & Boekelheide, Inc. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jun 11 12:29:05 2018 From: timr at probo.com (Tim Roberts) Date: Mon, 11 Jun 2018 09:29:05 -0700 Subject: [python-win32] Dispatching something that requires elevation In-Reply-To: References: Message-ID: <941fdb4b-93aa-4fb1-3e91-3d0f23551d5f@probo.com> Simon McConnell wrote: > > Sorry, I'm not sure what you mean by spawn the COM access in a > separate process.? This is my first time dabbling with COM objects. All I meant was creating a second Python process to do all the COM stuff.? I think you said that the COM access works from a non-elevated process, but that you need elevation for other parts of your app.? Thus, if you put the COM access into its own (non-elevated) process, you might be able to make things work, although you'd need a way to communicate between your two processes.? Still, it doesn't make sense to me that the COM server would care that its client was elevated.? There are aspects to this that I don't understand. > Is there a neat way to kill all the tasks that you've started when > your script fails without hitting the application's Quit call? This is all up to the COM server.? There's no COM-specific magic here. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sas.rockks at gmail.com Sat Jun 16 17:52:20 2018 From: sas.rockks at gmail.com (santosh sahu) Date: Sun, 17 Jun 2018 03:22:20 +0530 Subject: [python-win32] Fwd: opening a url in browser, when user clicks on windows notification In-Reply-To: References: Message-ID: Hi, I want to open a pop up notification on the web browser when a user clicks on the pop up notification. Right now I am able to show the notifications on windows10. Below is the link to the question asked on .Stackoverflow question Could you please provide the api's and any documentation which would solve the problem. Regards, Santosh ---------- Forwarded message ---------- From: santosh sahu Date: Sun, Jun 17, 2018 at 3:05 AM Subject: opening a url in browser, when user clicks on windows notification To: python-win32 at python.org Hi, -- Regards, Santosh Sahu Contact no.-+91-9986796629 -- Regards, Santosh Sahu Contact no.-+91-9986796629 -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sun Jun 17 02:51:10 2018 From: timr at probo.com (Tim Roberts) Date: Sat, 16 Jun 2018 23:51:10 -0700 Subject: [python-win32] opening a url in browser, when user clicks on windows notification In-Reply-To: References: Message-ID: <678A1225-0A72-41F3-9098-7289EB0EB134@probo.com> On Jun 16, 2018, at 2:52 PM, santosh sahu wrote: > > I want to open a pop up notification on the web browser when a user clicks on the pop up notification. Right now I am able to show the notifications on windows10. Below is the link to the question asked on .Stackoverflow question > Could you please provide the api's and any documentation which would solve the problem. I don't understand what you're asking. You have a script that shows a pop-up desktop notification. There's nothing web-based here at all. How is a browser getting involved? ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From killermilind at gmail.com Mon Jun 18 12:28:42 2018 From: killermilind at gmail.com (Milind R) Date: Mon, 18 Jun 2018 21:58:42 +0530 Subject: [python-win32] Run script language=Python scripts in IE11 on Windows10 Message-ID: Hi All, I am interested in tinkering with IE's active scripting in Python ( https://stackoverflow.com/a/6089948/517835). I am now on Windows 10 x64 1803, with IE11. I am aware of the lack of rexec in python, and the attendant warning. I am just trying to demonstrate it to myself for fun now, but have some ideas on what to do with it later..... Right now, I am unable to get the pywin32 demos at site-packages\win32comext\axscript\Demos\client\ie\ to run correctly in IE... I tried enabling and disabling Enhanced Protected Mode, but I think local files run with EPM disabled. I have verified that the Python.AXScript-rexec.2 key exists in the registry. I also tried to verify that iexplore.exe is a 64-bit process, but I'm not even sure if there are other, bigger pieces broken here. I am able to run WSH scripts, so the Python script engine itself is running, but something else is the problem. Some help here would be great. Regards, Milind -------------- next part -------------- An HTML attachment was scrubbed... URL: From rob.marshall17 at gmail.com Tue Jun 26 00:12:57 2018 From: rob.marshall17 at gmail.com (Rob Marshall) Date: Tue, 26 Jun 2018 00:12:57 -0400 Subject: [python-win32] How to get actual FILETIME from PyTime Message-ID: Hi, Is there a way to get the actual FILETIME value from a PyTime? Thanks, Rob From webguy at totalrewind.com Tue Jun 26 18:14:34 2018 From: webguy at totalrewind.com (Kurt Eilander) Date: Tue, 26 Jun 2018 16:14:34 -0600 Subject: [python-win32] Dragdrop shell extension? Message-ID: <6713c581-673f-261b-6e84-7494390bf7b5@totalrewind.com> Hey all, I've implemented a file format called .urls which is a plain text file containing (guess what) urls. I've successfully registered it with a python script so it can, when clicked, open a new browser windows with all of the urls listed in new tabs. (Very handy!) Now, I want to be able to drop handler such that a link dragged from the browser (system .url file, basically) onto the .urls file will append the new link to those in the list. I understand that file formats which do this sort of thing register a program as a shell extension, but how do I write such a thing to handle shell dragdrop in python?? Thanks, -K From rob.marshall17 at gmail.com Wed Jun 27 01:04:26 2018 From: rob.marshall17 at gmail.com (Rob Marshall) Date: Wed, 27 Jun 2018 01:04:26 -0400 Subject: [python-win32] Where is MakeAbsoluteSD? Message-ID: Hi, I'm trying to convert a self-relative security descriptor, i.e. the type that is returned by win32security.ConvertStringSecurityDescriptorToSecurityDescriptor(), to an absolute SD but I can't seem to find the MakeAbsoluteSD() function. Where is it? Thanks, Rob From eryksun at gmail.com Wed Jun 27 02:22:31 2018 From: eryksun at gmail.com (eryk sun) Date: Wed, 27 Jun 2018 06:22:31 +0000 Subject: [python-win32] Where is MakeAbsoluteSD? In-Reply-To: References: Message-ID: On Wed, Jun 27, 2018 at 5:04 AM, Rob Marshall wrote: > > I'm trying to convert a self-relative security descriptor, i.e. the > type that is returned by > win32security.ConvertStringSecurityDescriptorToSecurityDescriptor(), > to an absolute SD but I can't seem to find the MakeAbsoluteSD() > function. Where is it? A PySECURITY_DESCRIPTOR object is stored in self-relative format. Internally it's converted to absolute format for functions that require it, such as SetSecurityDescriptorDacl. See the source: https://github.com/mhammond/pywin32/blob/b223/win32/src/PySECURITY_DESCRIPTOR.cpp From ckkart at hoc.net Wed Jun 27 09:07:17 2018 From: ckkart at hoc.net (ckkart at hoc.net) Date: Wed, 27 Jun 2018 10:07:17 -0300 Subject: [python-win32] =?utf-8?q?Dragdrop_shell_extension=3F?= In-Reply-To: <6713c581-673f-261b-6e84-7494390bf7b5@totalrewind.com> References: <6713c581-673f-261b-6e84-7494390bf7b5@totalrewind.com> Message-ID: <912f7d9aa60786599c131fdec10344a3@www.hoc.net> Am 2018-06-26 19:14, schrieb webguy at totalrewind.com: > Now, I want to be able to drop handler such that a link dragged from > the browser (system .url file, basically) onto the .urls file will > append the new link to those in the list. > > I understand that file formats which do this sort of thing register a > program as a shell extension, but how do I write such a thing to > handle shell dragdrop in python?? Have you had a look at the the \win32comext\shell\demos folder? Maybe there is something useful. Christian From timr at probo.com Wed Jun 27 13:38:08 2018 From: timr at probo.com (Tim Roberts) Date: Wed, 27 Jun 2018 10:38:08 -0700 Subject: [python-win32] How to get actual FILETIME from PyTime In-Reply-To: References: Message-ID: <176352e6-d597-af36-219a-dd6de85bb5fc@probo.com> Rob Marshall wrote: > Is there a way to get the actual FILETIME value from a PyTime? PyTime isn't actually a type.? It's just a set of conversion routines that produce standard datetime values.? So, your question really is "how to convert a datetime to a Windows FILETIME"?? And here's a Python module that can do that: ??? https://gist.github.com/Mostafa-Hamdy-Elgiar/9714475f1b3bc224ea063af81566d873 -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From eryksun at gmail.com Wed Jun 27 16:42:07 2018 From: eryksun at gmail.com (eryk sun) Date: Wed, 27 Jun 2018 20:42:07 +0000 Subject: [python-win32] Where is MakeAbsoluteSD? In-Reply-To: References: Message-ID: On Wed, Jun 27, 2018 at 3:14 PM, Rob Marshall wrote: > > I saw that, my problem is that I'm trying to use > win32security.ConvertSecurityDescriptorToStringSecurityDescriptor() > which is returning a self-relative SDDL and I need one that is > absolute. Is there a flag that I can set and get an absolute SDDL from > that function? In the Microsoft documentation for > ConvertSecurityDescriptorToStringSecurityDescriptor() it says, as to > what it "returns": Again, it doesn't matter what form the WinAPI function returns. Whatever it is, the PySECURITY_DESCRIPTOR object internally converts it to self-relative format. Why do you need an absolute format SD? Whatever the reason you'll need to use ctypes for part of the problem. From rob.marshall17 at gmail.com Wed Jun 27 11:14:44 2018 From: rob.marshall17 at gmail.com (Rob Marshall) Date: Wed, 27 Jun 2018 11:14:44 -0400 Subject: [python-win32] Where is MakeAbsoluteSD? In-Reply-To: References: Message-ID: Hi, I saw that, my problem is that I'm trying to use win32security.ConvertSecurityDescriptorToStringSecurityDescriptor() which is returning a self-relative SDDL and I need one that is absolute. Is there a flag that I can set and get an absolute SDDL from that function? In the Microsoft documentation for ConvertSecurityDescriptorToStringSecurityDescriptor() it says, as to what it "returns": A pointer to a variable that receives a pointer to the converted security descriptor. The returned security descriptor is self-relative. To free the returned buffer, call the LocalFree function. To convert the security descriptor to an absolute security descriptor, use the MakeAbsoluteSD function. Thanks, Rob On Wed, Jun 27, 2018 at 2:23 AM eryk sun wrote: > > On Wed, Jun 27, 2018 at 5:04 AM, Rob Marshall wrote: > > > > I'm trying to convert a self-relative security descriptor, i.e. the > > type that is returned by > > win32security.ConvertStringSecurityDescriptorToSecurityDescriptor(), > > to an absolute SD but I can't seem to find the MakeAbsoluteSD() > > function. Where is it? > > A PySECURITY_DESCRIPTOR object is stored in self-relative format. > Internally it's converted to absolute format for functions that > require it, such as SetSecurityDescriptorDacl. See the source: > > https://github.com/mhammond/pywin32/blob/b223/win32/src/PySECURITY_DESCRIPTOR.cpp From rob.marshall17 at gmail.com Thu Jun 28 00:45:31 2018 From: rob.marshall17 at gmail.com (Rob Marshall) Date: Thu, 28 Jun 2018 00:45:31 -0400 Subject: [python-win32] How to get actual FILETIME from PyTime In-Reply-To: <176352e6-d597-af36-219a-dd6de85bb5fc@probo.com> References: <176352e6-d597-af36-219a-dd6de85bb5fc@probo.com> Message-ID: Thank-you. I also figured out that if I want the "actual" FILETIME I can do: >>> get_filetime = lambda i: ((i & 0xffffffff),(i - (i & 0xffffffff))>>32) >>> get_filetime(131742277260000000) (905689856L, 30673639L) >>> low,high = get_filetime(131742277260000000) >>> (high<<32)+low 131742277260000000L On Wed, Jun 27, 2018 at 1:49 PM Tim Roberts wrote: > > Rob Marshall wrote: > > Is there a way to get the actual FILETIME value from a PyTime? > > PyTime isn't actually a type. It's just a set of conversion routines > that produce standard datetime values. So, your question really is "how > to convert a datetime to a Windows FILETIME"? And here's a Python > module that can do that: > > > https://gist.github.com/Mostafa-Hamdy-Elgiar/9714475f1b3bc224ea063af81566d873 > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 From rob.marshall17 at gmail.com Thu Jun 28 00:49:47 2018 From: rob.marshall17 at gmail.com (Rob Marshall) Date: Thu, 28 Jun 2018 00:49:47 -0400 Subject: [python-win32] Where is MakeAbsoluteSD? In-Reply-To: References: Message-ID: Hi, At the moment I don't need it at all, but when I use the smbcacls utility from Samba on a Linux system and have it print the security descriptor as an SDDL it gives me something like: O:S-1-5-21-3327876616-1579407131-3503203118-500G:S-1-5-21-3327876616-1579407131-3503203118-513D:P(A;;0x001e01ff;;;S-1-5-21-3327876616-1579407131-3503203118-500)(A;;0x00120089;;;S-1-5-21-3327876616-1579407131-3503203118-513)(A;;0x00120089;;;WD That's what I was hoping to get so that I could print it out. Currently it doesn't matter because I can use smbcacls to get what I want. Rob On Wed, Jun 27, 2018 at 4:42 PM eryk sun wrote: > > On Wed, Jun 27, 2018 at 3:14 PM, Rob Marshall wrote: > > > > I saw that, my problem is that I'm trying to use > > win32security.ConvertSecurityDescriptorToStringSecurityDescriptor() > > which is returning a self-relative SDDL and I need one that is > > absolute. Is there a flag that I can set and get an absolute SDDL from > > that function? In the Microsoft documentation for > > ConvertSecurityDescriptorToStringSecurityDescriptor() it says, as to > > what it "returns": > > Again, it doesn't matter what form the WinAPI function returns. > Whatever it is, the PySECURITY_DESCRIPTOR object internally converts > it to self-relative format. Why do you need an absolute format SD? > Whatever the reason you'll need to use ctypes for part of the problem. From eryksun at gmail.com Thu Jun 28 06:46:18 2018 From: eryksun at gmail.com (eryk sun) Date: Thu, 28 Jun 2018 10:46:18 +0000 Subject: [python-win32] Where is MakeAbsoluteSD? In-Reply-To: References: Message-ID: On Thu, Jun 28, 2018 at 4:49 AM, Rob Marshall wrote: > Hi, > > At the moment I don't need it at all, but when I use the smbcacls > utility from Samba on a Linux system and have it print the security > descriptor as an SDDL it gives me something like: > > O:S-1-5-21-3327876616-1579407131-3503203118-500G:S-1-5-21-3327876616- > 1579407131-3503203118-513D:P(A;;0x001e01ff;;;S-1-5-21-3327876616- > 1579407131-3503203118-500)(A;;0x00120089;;;S-1-5-21-3327876616- > 1579407131-3503203118-513)(A;;0x00120089;;;WD > > That's what I was hoping to get so that I could print it out. > Currently it doesn't matter because I can use smbcacls to get what I > want. There is no such thing as an absolute format SDDL string. Do you understand that "absolute" in this case is referring to absolute pointer addresses for the SD components *in memory*? This is opposed to the relative offset format that's used when marshaling the structure to disk or over the wire. The distinction is completely irrelevant to the SDDL string representation of an SD. The conversion from SDDL to SD always creates a self-relative format SD. It's also not relevant within the PyWin32 framework, since a PySECURITY_DESCRIPTOR is stored in self-relative format and automatically converts to absolute format whenever that's required. The boring details are handled for you automatically. From timr at probo.com Thu Jun 28 13:44:18 2018 From: timr at probo.com (Tim Roberts) Date: Thu, 28 Jun 2018 10:44:18 -0700 Subject: [python-win32] How to get actual FILETIME from PyTime In-Reply-To: References: <176352e6-d597-af36-219a-dd6de85bb5fc@probo.com> Message-ID: Rob Marshall wrote: > Thank-you. I also figured out that if I want the "actual" FILETIME I can do: > >>>> get_filetime = lambda i: ((i & 0xffffffff),(i - (i & 0xffffffff))>>32) >>>> get_filetime(131742277260000000) > (905689856L, 30673639L) >>>> low,high = get_filetime(131742277260000000) >>>> (high<<32)+low > 131742277260000000L A FILETIME is just a 64-bit integer, and you can always pass it to APIs that way.? The only reason the structure has it in two parts is because the Microsoft C compilers of the early 1990s did not have a 64-bit type. Another way to do the unpacking is ??? struct.unpack('II',struct.pack('Q',i)) and the reverse: ??? struct.unpack('Q','strict.pack('II',low,high)[0] -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.