From balexjewell at gmail.com Tue Jan 5 16:29:10 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Tue, 5 Jan 2016 16:29:10 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python Message-ID: So, thanks to the Tim Golden guide (http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) and other questions on Stack Overflow I have a script that will show overlays on files and folders based on their "state" similar to Tortoise SVN or Dropbox. Works great. My problem is that once I restart the explorer.exe process or the OS itself and open explorer there are no longer any overlays. My first thought: - Have the service that actually manages file state detect that no requests have come in and just re-register the overlay handler The problem here is that registration requires elevated permissions which is acceptable on initial install of the application by the end user but not every time they restart their machine. Can anyone suggest what I might be missing here? I have the class BaseOverlay and its children in a single .py file and register from my main app by calling this script using subprocess. subprocess.check_call("C:\scripts\register_overlays.py", shell=True) Is Explorer not able to re-load the script as it is Python? Do I need to compile into a DLL or EXE? Would that change the registration process? Here's the registration call: win32com.server.register.UseCommandLine(BaseOverlay) Here's the class(simplified): class BaseOverlay: _reg_clsid_ = '{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}' _reg_progid_ = 'someoverlays' _reg_desc_ = 'Icon Overlay Handler' _public_methods_ = ['GetOverlayInfo', 'GetPriority', 'IsMemberOf'] _com_interfaces_ = [shell.IID_IShellIconOverlayIdentifier] def GetOverlayInfo(self): return icon_path, 0, shellcon.ISIOI_ICONFILE def GetPriority(self): return 50 def IsMemberOf(self, fname, attributes): return winerror.S_OK Thanks for any help you can provide, Alex Jewell -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Jan 6 05:37:29 2016 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 6 Jan 2016 21:37:29 +1100 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: Message-ID: My guess is that the environment (eg, PATH, PYTHONPATH etc) for the new explorer instance isn't setup correctly - how is the explorer.exe process started when it *does* work? It's hard to answer without more info, but Python ends up inside explorer.exe, so the environment that explorer.exe starts with is important. Mark On 6/01/2016 8:29 AM, Alexander Jewell wrote: > So, thanks to the Tim Golden guide > (http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) and > other questions > on > Stack Overflow I have a script that will show overlays on files and > folders based on their "state" similar to Tortoise SVN or Dropbox. Works > great. > > My problem is that once I restart the explorer.exe process or the OS > itself and open explorer there are no longer any overlays. > > My first thought: > > * Have the service that actually manages file state detect that no > requests have come in and just re-register the overlay handler > > The problem here is that registration requires elevated permissions > which is acceptable on initial install of the application by the end > user but not every time they restart their machine. > > Can anyone suggest what I might be missing here? I have the class > BaseOverlay and its children in a single .py file and register from my > main app by calling this script using subprocess. > > |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| > > Is Explorer not able to re-load the script as it is Python? Do I need to > compile into a DLL or EXE? Would that change the registration process? > > Here's the registration call: > > |win32com.server.register.UseCommandLine(BaseOverlay)| > > Here's the class(simplified): > > |classBaseOverlay:_reg_clsid_ > ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ > ='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_ > =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ > =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE > defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| > > Thanks for any help you can provide, > > Alex Jewell > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Wed Jan 6 19:19:52 2016 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 7 Jan 2016 11:19:52 +1100 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: Message-ID: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> On 7/01/2016 6:21 AM, Alexander Jewell wrote: > Unfortunately my end goal was to bundle the entire application as an exe > with PyInstaller so that the end user does not actually have Python > installed. > > Do you think it would be possible to package the overlay handler in such > a way that explorer would not need access to an installed Python > interpreter? > Embedding(https://docs.python.org/3.4/extending/embedding.html) seems > to still require a Python interpreter but Cython sounds promising. I've used py2exe for this in the past and it works fine - you need to end up with a stand-alone directory that functions independently of any installed Python - py2exe bundles Python itself, pywin32, etc in just this way. Last I tried though, it only worked with python 2.x Mark > > -Alex > > On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond > wrote: > > My guess is that the environment (eg, PATH, PYTHONPATH etc) for the > new explorer instance isn't setup correctly - how is the > explorer.exe process started when it *does* work? It's hard to > answer without more info, but Python ends up inside explorer.exe, so > the environment that explorer.exe starts with is important. > > Mark > > On 6/01/2016 8:29 AM, Alexander Jewell wrote: > > So, thanks to the Tim Golden guide > > (http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) > and > other questions > > on > Stack Overflow I have a script that will show overlays on files and > folders based on their "state" similar to Tortoise SVN or > Dropbox. Works > great. > > My problem is that once I restart the explorer.exe process or the OS > itself and open explorer there are no longer any overlays. > > My first thought: > > * Have the service that actually manages file state detect that no > requests have come in and just re-register the overlay handler > > The problem here is that registration requires elevated permissions > which is acceptable on initial install of the application by the end > user but not every time they restart their machine. > > Can anyone suggest what I might be missing here? I have the class > BaseOverlay and its children in a single .py file and register > from my > main app by calling this script using subprocess. > > |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| > > Is Explorer not able to re-load the script as it is Python? Do I > need to > compile into a DLL or EXE? Would that change the registration > process? > > Here's the registration call: > > |win32com.server.register.UseCommandLine(BaseOverlay)| > > Here's the class(simplified): > > |classBaseOverlay:_reg_clsid_ > ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ > ='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_ > =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ > =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE > defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| > > Thanks for any help you can provide, > > Alex Jewell > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > From balexjewell at gmail.com Wed Jan 6 14:21:10 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Wed, 6 Jan 2016 14:21:10 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: Message-ID: Thanks for the reply Mark. That makes sense, I hadn't thought about the environment. During development I'm testing in a virtual environment which contains Python 3.4 and all the required libraries. The explorer.exe process is killed and started by the same process (within the same script) that registers using win32com.server.register.UseCommandLine. When I restart the machine or restart explorer.exe via Task Manager, it would be using the default Python for the machine (Python3.5) without any of the required libraries so if I understand correctly explorer would attempt to run BaseOverlay using the wrong version of Python and without access to win32com which is only in the virtualenv. Unfortunately my end goal was to bundle the entire application as an exe with PyInstaller so that the end user does not actually have Python installed. Do you think it would be possible to package the overlay handler in such a way that explorer would not need access to an installed Python interpreter? Embedding(https://docs.python.org/3.4/extending/embedding.html) seems to still require a Python interpreter but Cython sounds promising. -Alex On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond wrote: > My guess is that the environment (eg, PATH, PYTHONPATH etc) for the new > explorer instance isn't setup correctly - how is the explorer.exe process > started when it *does* work? It's hard to answer without more info, but > Python ends up inside explorer.exe, so the environment that explorer.exe > starts with is important. > > Mark > > On 6/01/2016 8:29 AM, Alexander Jewell wrote: > >> So, thanks to the Tim Golden guide >> < >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html> >> ( >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) >> and >> other questions >> < >> http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python#> >> on >> Stack Overflow I have a script that will show overlays on files and >> folders based on their "state" similar to Tortoise SVN or Dropbox. Works >> great. >> >> My problem is that once I restart the explorer.exe process or the OS >> itself and open explorer there are no longer any overlays. >> >> My first thought: >> >> * Have the service that actually manages file state detect that no >> requests have come in and just re-register the overlay handler >> >> The problem here is that registration requires elevated permissions >> which is acceptable on initial install of the application by the end >> user but not every time they restart their machine. >> >> Can anyone suggest what I might be missing here? I have the class >> BaseOverlay and its children in a single .py file and register from my >> main app by calling this script using subprocess. >> >> |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| >> >> Is Explorer not able to re-load the script as it is Python? Do I need to >> compile into a DLL or EXE? Would that change the registration process? >> >> Here's the registration call: >> >> |win32com.server.register.UseCommandLine(BaseOverlay)| >> >> Here's the class(simplified): >> >> |classBaseOverlay:_reg_clsid_ >> ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ >> ='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_ >> =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ >> >> =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE >> >> defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| >> >> Thanks for any help you can provide, >> >> Alex Jewell >> >> >> >> >> _______________________________________________ >> 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 balexjewell at gmail.com Fri Jan 8 15:30:58 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Fri, 8 Jan 2016 15:30:58 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> Message-ID: I created a fresh Python 2.7 environment with pywin and py2exe and stripped down my overlay handler to the basics to better troubleshoot. Running my script (command line or in PyCharm) registers everything correctly, just like before, but running the py2exe generated EXE seems to be registering but no overlays are appearing, which looks just like what happens when I restarted explorer.exe in my previous attempt (logged messages during registration, plus a manual check of the registry look good but nothing generated by IsMemberOf. I'm going to try generating a DLL and manually registering following the example here: http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 It looks like this example came out of a mail thread with you back in 2011 so I'll try to follow the advice there and report back. Thanks again for the help Mark. On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond wrote: > On 7/01/2016 6:21 AM, Alexander Jewell wrote: > >> Unfortunately my end goal was to bundle the entire application as an exe >> with PyInstaller so that the end user does not actually have Python >> installed. >> >> Do you think it would be possible to package the overlay handler in such >> a way that explorer would not need access to an installed Python >> interpreter? >> Embedding(https://docs.python.org/3.4/extending/embedding.html) seems >> to still require a Python interpreter but Cython sounds promising. >> > > I've used py2exe for this in the past and it works fine - you need to end > up with a stand-alone directory that functions independently of any > installed Python - py2exe bundles Python itself, pywin32, etc in just this > way. Last I tried though, it only worked with python 2.x > > Mark > > >> -Alex >> >> On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond > > wrote: >> >> My guess is that the environment (eg, PATH, PYTHONPATH etc) for the >> new explorer instance isn't setup correctly - how is the >> explorer.exe process started when it *does* work? It's hard to >> answer without more info, but Python ends up inside explorer.exe, so >> the environment that explorer.exe starts with is important. >> >> Mark >> >> On 6/01/2016 8:29 AM, Alexander Jewell wrote: >> >> So, thanks to the Tim Golden guide >> < >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> > >> ( >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> ) >> and >> other questions >> < >> http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python# >> > >> on >> Stack Overflow I have a script that will show overlays on files >> and >> folders based on their "state" similar to Tortoise SVN or >> Dropbox. Works >> great. >> >> My problem is that once I restart the explorer.exe process or the >> OS >> itself and open explorer there are no longer any overlays. >> >> My first thought: >> >> * Have the service that actually manages file state detect that >> no >> requests have come in and just re-register the overlay handler >> >> The problem here is that registration requires elevated >> permissions >> which is acceptable on initial install of the application by the >> end >> user but not every time they restart their machine. >> >> Can anyone suggest what I might be missing here? I have the class >> BaseOverlay and its children in a single .py file and register >> from my >> main app by calling this script using subprocess. >> >> >> |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| >> >> Is Explorer not able to re-load the script as it is Python? Do I >> need to >> compile into a DLL or EXE? Would that change the registration >> process? >> >> Here's the registration call: >> >> |win32com.server.register.UseCommandLine(BaseOverlay)| >> >> Here's the class(simplified): >> >> |classBaseOverlay:_reg_clsid_ >> ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ >> ='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_ >> =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ >> >> =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE >> >> defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| >> >> Thanks for any help you can provide, >> >> Alex Jewell >> >> >> >> >> _______________________________________________ >> 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 David.Manowitz at eia.gov Mon Jan 11 12:21:30 2016 From: David.Manowitz at eia.gov (Manowitz, David) Date: Mon, 11 Jan 2016 17:21:30 +0000 Subject: [python-win32] Calling unregistered COM libraries via Python Message-ID: Is it possible, either via the win32com extensions or the comtypes package (or some other package), to call to an unregistered COM library? It doesn't seem so, but I wanted to check. Thanks, David Manowitz Office of Petroleum, Natural Gas, and Biofuels Analysis Energy Information Administration U.S. Department of Energy 1000 Independence Ave S.W. Washington, DC 20585 Tel: +1-202-586-2815 -------------- next part -------------- An HTML attachment was scrubbed... URL: From balexjewell at gmail.com Mon Jan 11 12:44:11 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Mon, 11 Jan 2016 12:44:11 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> Message-ID: Hi Mark, I followed your suggestion and the SO threads touching on this area. ( http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 ) Using py2exe I generated a dist folder with an exe of my overlay script. Running this on a machine without Python installed shows all of the proper log messages being generated and registry entry created for my overlay handler, however there's no indication that explorer is loading and running the overlay handler. Following the SO examples I instead generated a COM DLL from the same source. I can copy this dist directory and new DLL over to a machine without Python and use regsrv32 to register the DLL without errors, but it doesn't run the main method which is what sets the required registry entries and calls UseCommandLine so it doesn't look like it's being registered correctly at all. Sorry for the newb questions, but I seem to have a big gap in my understanding of the mechanism. So, the way that I'm using it at least, py2exe is either generating an EXE that will register correctly but not provide a COM object with the correct environment for explorer to run the overlay handler, or a DLL that should be self contained and functional but not provide the registration functionality. I've attached my primary script (Overlay Handler + logging and some helper objects) as well as 2 py2exe setup scripts I've tried. I'm hoping you can point out a huge flaw in my thinking, or an obvious step that I'm missing in the registration process. Thanks again for any help you can provide. On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell wrote: > I created a fresh Python 2.7 environment with pywin and py2exe and > stripped down my overlay handler to the basics to better troubleshoot. > > Running my script (command line or in PyCharm) registers everything > correctly, just like before, but running the py2exe generated EXE seems to > be registering but no overlays are appearing, which looks just like what > happens when I restarted explorer.exe in my previous attempt (logged > messages during registration, plus a manual check of the registry look good > but nothing generated by IsMemberOf. > > I'm going to try generating a DLL and manually registering following the > example here: > http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 > > It looks like this example came out of a mail thread with you back in 2011 > so I'll try to follow the advice there and report back. > > Thanks again for the help Mark. > > On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond > wrote: > >> On 7/01/2016 6:21 AM, Alexander Jewell wrote: >> >>> Unfortunately my end goal was to bundle the entire application as an exe >>> with PyInstaller so that the end user does not actually have Python >>> installed. >>> >>> Do you think it would be possible to package the overlay handler in such >>> a way that explorer would not need access to an installed Python >>> interpreter? >>> Embedding(https://docs.python.org/3.4/extending/embedding.html) seems >>> to still require a Python interpreter but Cython sounds promising. >>> >> >> I've used py2exe for this in the past and it works fine - you need to end >> up with a stand-alone directory that functions independently of any >> installed Python - py2exe bundles Python itself, pywin32, etc in just this >> way. Last I tried though, it only worked with python 2.x >> >> Mark >> >> >>> -Alex >>> >>> On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond >> > wrote: >>> >>> My guess is that the environment (eg, PATH, PYTHONPATH etc) for the >>> new explorer instance isn't setup correctly - how is the >>> explorer.exe process started when it *does* work? It's hard to >>> answer without more info, but Python ends up inside explorer.exe, so >>> the environment that explorer.exe starts with is important. >>> >>> Mark >>> >>> On 6/01/2016 8:29 AM, Alexander Jewell wrote: >>> >>> So, thanks to the Tim Golden guide >>> < >>> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >>> > >>> ( >>> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >>> ) >>> and >>> other questions >>> < >>> http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python# >>> > >>> on >>> Stack Overflow I have a script that will show overlays on files >>> and >>> folders based on their "state" similar to Tortoise SVN or >>> Dropbox. Works >>> great. >>> >>> My problem is that once I restart the explorer.exe process or >>> the OS >>> itself and open explorer there are no longer any overlays. >>> >>> My first thought: >>> >>> * Have the service that actually manages file state detect >>> that no >>> requests have come in and just re-register the overlay >>> handler >>> >>> The problem here is that registration requires elevated >>> permissions >>> which is acceptable on initial install of the application by the >>> end >>> user but not every time they restart their machine. >>> >>> Can anyone suggest what I might be missing here? I have the class >>> BaseOverlay and its children in a single .py file and register >>> from my >>> main app by calling this script using subprocess. >>> >>> >>> |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| >>> >>> Is Explorer not able to re-load the script as it is Python? Do I >>> need to >>> compile into a DLL or EXE? Would that change the registration >>> process? >>> >>> Here's the registration call: >>> >>> |win32com.server.register.UseCommandLine(BaseOverlay)| >>> >>> Here's the class(simplified): >>> >>> |classBaseOverlay:_reg_clsid_ >>> ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ >>> ='someoverlays'_reg_desc_ ='Icon Overlay Handler'_public_methods_ >>> =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ >>> >>> =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE >>> >>> defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| >>> >>> Thanks for any help you can provide, >>> >>> Alex Jewell >>> >>> >>> >>> >>> _______________________________________________ >>> 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: overlays.py Type: text/x-python-script Size: 4917 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: setup_2.py Type: text/x-python-script Size: 451 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: setup.py Type: text/x-python-script Size: 1181 bytes Desc: not available URL: From mhammond at skippinet.com.au Mon Jan 11 17:43:30 2016 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Jan 2016 09:43:30 +1100 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> Message-ID: <97aa2c89-6e91-d03f-94e1-48b4952e33b3@skippinet.com.au> setup_2.py has: > setup(console=['overlays.py']) So that's going to create a console program with no COM support. setup.py has: > # specify which type of com server you want (exe and/or dll) > create_exe=True, > create_dll=False So you are only going to get a COM object that can be created as a .exe. Explorer wants only inproc objects (ie, those hosted in a DLL), so you want create_dll=True and create_exe=False - you should then get a DLL you can register with regsvr32. HTH, Mark On 12/01/2016 4:44 AM, Alexander Jewell wrote: > Hi Mark, > > I followed your suggestion and the SO threads touching on this area. > (http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7) > Using py2exe I generated a dist folder with an exe of my overlay script. > Running this on a machine without Python installed shows all of the > proper log messages being generated and registry entry created for my > overlay handler, however there's no indication that explorer is loading > and running the overlay handler. > > Following the SO examples I instead generated a COM DLL from the same > source. I can copy this dist directory and new DLL over to a machine > without Python and use regsrv32 to register the DLL without errors, but > it doesn't run the main method which is what sets the required registry > entries and calls UseCommandLine so it doesn't look like it's being > registered correctly at all. > > Sorry for the newb questions, but I seem to have a big gap in my > understanding of the mechanism. > > So, the way that I'm using it at least, py2exe is either generating an > EXE that will register correctly but not provide a COM object with the > correct environment for explorer to run the overlay handler, or a DLL > that should be self contained and functional but not provide the > registration functionality. > > I've attached my primary script (Overlay Handler + logging and some > helper objects) as well as 2 py2exe setup scripts I've tried. > > I'm hoping you can point out a huge flaw in my thinking, or an obvious > step that I'm missing in the registration process. > > Thanks again for any help you can provide. > > > On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell > wrote: > > I created a fresh Python 2.7 environment with pywin and py2exe and > stripped down my overlay handler to the basics to better troubleshoot. > > Running my script (command line or in PyCharm) registers everything > correctly, just like before, but running the py2exe generated EXE > seems to be registering but no overlays are appearing, which looks > just like what happens when I restarted explorer.exe in my previous > attempt (logged messages during registration, plus a manual check of > the registry look good but nothing generated by IsMemberOf. > > I'm going to try generating a DLL and manually registering following > the example > here: http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 > > It looks like this example came out of a mail thread with you back > in 2011 so I'll try to follow the advice there and report back. > > Thanks again for the help Mark. > > On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond > > wrote: > > On 7/01/2016 6:21 AM, Alexander Jewell wrote: > > Unfortunately my end goal was to bundle the entire > application as an exe > with PyInstaller so that the end user does not actually have > Python > installed. > > Do you think it would be possible to package the overlay > handler in such > a way that explorer would not need access to an installed Python > interpreter? > Embedding(https://docs.python.org/3.4/extending/embedding.html) > seems > to still require a Python interpreter but Cython sounds > promising. > > > I've used py2exe for this in the past and it works fine - you > need to end up with a stand-alone directory that functions > independently of any installed Python - py2exe bundles Python > itself, pywin32, etc in just this way. Last I tried though, it > only worked with python 2.x > > Mark > > > -Alex > > On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond > > >> wrote: > > My guess is that the environment (eg, PATH, PYTHONPATH > etc) for the > new explorer instance isn't setup correctly - how is the > explorer.exe process started when it *does* work? It's > hard to > answer without more info, but Python ends up inside > explorer.exe, so > the environment that explorer.exe starts with is important. > > Mark > > On 6/01/2016 8:29 AM, Alexander Jewell wrote: > > So, thanks to the Tim Golden guide > > > > (http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) > and > other questions > > > on > Stack Overflow I have a script that will show > overlays on files and > folders based on their "state" similar to Tortoise > SVN or > Dropbox. Works > great. > > My problem is that once I restart the explorer.exe > process or the OS > itself and open explorer there are no longer any > overlays. > > My first thought: > > * Have the service that actually manages file > state detect that no > requests have come in and just re-register the > overlay handler > > The problem here is that registration requires > elevated permissions > which is acceptable on initial install of the > application by the end > user but not every time they restart their machine. > > Can anyone suggest what I might be missing here? I > have the class > BaseOverlay and its children in a single .py file > and register > from my > main app by calling this script using subprocess. > > > |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| > > Is Explorer not able to re-load the script as it is > Python? Do I > need to > compile into a DLL or EXE? Would that change the > registration > process? > > Here's the registration call: > > |win32com.server.register.UseCommandLine(BaseOverlay)| > > Here's the class(simplified): > > |classBaseOverlay:_reg_clsid_ > ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ > ='someoverlays'_reg_desc_ ='Icon Overlay > Handler'_public_methods_ > > =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ > > =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE > > defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| > > Thanks for any help you can provide, > > Alex Jewell > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > > > > https://mail.python.org/mailman/listinfo/python-win32 > > > > > From skippy.hammond at gmail.com Mon Jan 11 17:55:25 2016 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 12 Jan 2016 09:55:25 +1100 Subject: [python-win32] Calling unregistered COM libraries via Python In-Reply-To: References: Message-ID: <55e34712-7e89-550d-67fc-038ebaa6f682@gmail.com> On 12/01/2016 4:21 AM, Manowitz, David wrote: > Is it possible, either via the win32com extensions or the comtypes > package (or some other package), to call to an unregistered COM > library? It doesn?t seem so, but I wanted to check. COM uses the registration info to locate and load the library, so in general it's not possible. You could always just register it though... Mark > > > > Thanks, > > David Manowitz > > Office of Petroleum, Natural Gas, and Biofuels Analysis > > Energy Information Administration > > U.S. Department of Energy > > 1000 Independence Ave S.W. > > Washington, DC 20585 > > Tel: +1-202-586-2815 > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > From David.Manowitz at eia.gov Mon Jan 11 18:04:48 2016 From: David.Manowitz at eia.gov (Manowitz, David) Date: Mon, 11 Jan 2016 23:04:48 +0000 Subject: [python-win32] Calling unregistered COM libraries via Python In-Reply-To: <55e34712-7e89-550d-67fc-038ebaa6f682@gmail.com> References: , <55e34712-7e89-550d-67fc-038ebaa6f682@gmail.com> Message-ID: Since I knew the path to the library, I wasn't sure if that was the case, but I guess so. --David -------- Original message -------- From: Mark Hammond Date: 1/11/2016 5:55 PM (GMT-05:00) To: "Manowitz, David" , "'comtypes-users at lists.sourceforge.net'" , "'python-win32 at python.org'" Subject: Re: [python-win32] Calling unregistered COM libraries via Python On 12/01/2016 4:21 AM, Manowitz, David wrote: > Is it possible, either via the win32com extensions or the comtypes > package (or some other package), to call to an unregistered COM > library? It doesn?t seem so, but I wanted to check. COM uses the registration info to locate and load the library, so in general it's not possible. You could always just register it though... Mark > > > > Thanks, > > David Manowitz > > Office of Petroleum, Natural Gas, and Biofuels Analysis > > Energy Information Administration > > U.S. Department of Energy > > 1000 Independence Ave S.W. > > Washington, DC 20585 > > Tel: +1-202-586-2815 > > > > > > _______________________________________________ > 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 mhammond at skippinet.com.au Mon Jan 11 18:41:30 2016 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Jan 2016 10:41:30 +1100 Subject: [python-win32] [ANN] pywin32 build 220 released. Message-ID: Hi all, I'm happy to announce the release of pywin32 build 220. This release has addressed a number of bugs with previous builds (most notably failure to install in Python 3.5) and has added a few new features - I've appended the change log at the end of this mail. Downloads are available at: https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/ For initial support (eg, to ask questions about the release etc), please contact this mailing-list (python-win32 at python.org). If you want to report a bug, please do so at https://sf.net/projects/pywin32. As always, thanks to everyone who contributed to this release, both in terms of code and reporting bugs to the tracker. As usual, Roger Upole contributed a huge number of fixes and enhancements for this release - thanks! (Regarding SourceForge - I'm hoping to start a discussion soon about moving away from their platform due to some high-profile issues with their site. Given Python itself is moving to github in the future, it may make sense to move pywin32 there too. But in the interests of getting a build out that works with Python 3.5, I decided to stick with SourceForge for now. If your browser or adblocker reports the site as malicious, then you probably need to add an exception) Cheers, Mark Changes: Since build 219: ---------------- * win32com - sys.argv[0] may be set to a bytes object instead of a string on Python 3 when implementing an in-process COM object. * Fix that allows a property to be fetched on COM objects to work in more cases (Fredrik Orderud via patch #155) * Disabled exchange and exchdapi modules on Python 2.5 due to unresolved build issues. * Fix potential crash in SHGetIDListFromObject and SHGetFileInfo issues (rupole) * Allow GetShortPathName to handle long paths in unicode mode (ruple) * Fix intermittent crash in win32cred.CredRead() (bug #670, rupole) * Support PT_MV_BINARY MAPI properties, (patch #37) and many other MAPI improvements (Nick Czeczulin) * Fix username used with EvtOpenSession (bug #688, rupole) * Fix OutputDebugString encoding in wide builds (patch #142, rupole) From framstag at rus.uni-stuttgart.de Tue Jan 12 02:46:28 2016 From: framstag at rus.uni-stuttgart.de (Ulli Horlacher) Date: Tue, 12 Jan 2016 08:46:28 +0100 Subject: [python-win32] looking for testers Message-ID: <20160112074628.GA28662@rus.uni-stuttgart.de> I have written a Python client for F*EX(*). It is designed for Windows users, though it runs on UNIX, too. I am now looking for testers. If you are interested, I will give you an account. (*) Frams' Fast File EXchange is a service to send files of any size to any user anywhere in the internet: http://fex.rus.uni-stuttgart.de:8080/index.html -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mail: horlacher at tik.uni-stuttgart.de Universitaet Stuttgart Tel: ++49-711-68565868 Allmandring 30a Fax: ++49-711-682357 70550 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/ REF:<20160112074628.GA28662 at rus.uni-stuttgart.de> From greg.ewing at canterbury.ac.nz Tue Jan 12 05:12:00 2016 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 12 Jan 2016 23:12:00 +1300 Subject: [python-win32] Calling unregistered COM libraries via Python In-Reply-To: References: Message-ID: <5694D170.6060108@canterbury.ac.nz> Manowitz, David wrote: > Is it possible, either via the win32com extensions or the comtypes > package (or some other package), to call to an unregistered COM > library? It does appear to be possible, using a manifest file: https://msdn.microsoft.com/en-us/library/ms973913.aspx -- Greg From mc at mclaveau Tue Jan 12 13:28:10 2016 From: mc at mclaveau (mc at mclaveau) Date: Tue, 12 Jan 2016 19:28:10 +0100 Subject: [python-win32] [ANN] pywin32 build 220 released. In-Reply-To: References: Message-ID: <569545BA.1080405@mclaveau.com> Le 12.01.16 00:41, Mark Hammond a ?crit : > Hi all, > I'm happy to announce the release of pywin32 build 220. _____ _ _ _ |_ _|| |__ __ _ _ __ | | __ _ _ ___ _ _ | | | | | '_ \ / _` || '_ \ | |/ / | | | | / _ \ | | | | | | | | | | | || (_| || | | || < | |_| || (_) || |_| | |_| |_| |_| |_| \__,_||_| |_||_|\_\ \__, | \___/ \__,_| (_) |___/ -- Michel Claveau From balexjewell at gmail.com Tue Jan 12 14:09:19 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Tue, 12 Jan 2016 14:09:19 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: <97aa2c89-6e91-d03f-94e1-48b4952e33b3@skippinet.com.au> References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> <97aa2c89-6e91-d03f-94e1-48b4952e33b3@skippinet.com.au> Message-ID: I should have checked the setup file before attaching, that's actually from a third test I ran that tried running an EXE. In my earlier test I had create_dll = True. During that test I ran "regsvr32 overlays.dll" (with terminal running as Administrator) and got a success message, but no registry entries were added and none of the logging present in the class was triggered, so it didn't run the main method in the provided script or instantiate the class. Am I mistaken in thinking that regsvr32 of the DLL replaces the use of win32com.server.register.UseCommandLine? Do I actually need both? So I would need to: Run the python script which writes the overlay handler GUID to the registry and calls win32com.server.register.UseCommandLine Run (with elevated privileges) regsvr32 to register the DLL Restart explorer.exe process so that Explorer picks up the overlays Is this correct? If so, I would have to ship both the script and the DLL build from the script, which shouldn't be a problem; I guess I just assumed that having two copies of the same code was incorrect. Thanks for bearing with me Alex On Mon, Jan 11, 2016 at 5:43 PM, Mark Hammond wrote: > setup_2.py has: > > > setup(console=['overlays.py']) > > So that's going to create a console program with no COM support. setup.py > has: > > > # specify which type of com server you want (exe and/or dll) > > create_exe=True, > > create_dll=False > > So you are only going to get a COM object that can be created as a .exe. > Explorer wants only inproc objects (ie, those hosted in a DLL), so you want > create_dll=True and create_exe=False - you should then get a DLL you can > register with regsvr32. > > HTH, > > Mark > > > > On 12/01/2016 4:44 AM, Alexander Jewell wrote: > >> Hi Mark, >> >> I followed your suggestion and the SO threads touching on this area. >> ( >> http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 >> ) >> Using py2exe I generated a dist folder with an exe of my overlay script. >> Running this on a machine without Python installed shows all of the >> proper log messages being generated and registry entry created for my >> overlay handler, however there's no indication that explorer is loading >> and running the overlay handler. >> >> Following the SO examples I instead generated a COM DLL from the same >> source. I can copy this dist directory and new DLL over to a machine >> without Python and use regsrv32 to register the DLL without errors, but >> it doesn't run the main method which is what sets the required registry >> entries and calls UseCommandLine so it doesn't look like it's being >> registered correctly at all. >> >> Sorry for the newb questions, but I seem to have a big gap in my >> understanding of the mechanism. >> >> So, the way that I'm using it at least, py2exe is either generating an >> EXE that will register correctly but not provide a COM object with the >> correct environment for explorer to run the overlay handler, or a DLL >> that should be self contained and functional but not provide the >> registration functionality. >> >> I've attached my primary script (Overlay Handler + logging and some >> helper objects) as well as 2 py2exe setup scripts I've tried. >> >> I'm hoping you can point out a huge flaw in my thinking, or an obvious >> step that I'm missing in the registration process. >> >> Thanks again for any help you can provide. >> >> >> On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell > > wrote: >> >> I created a fresh Python 2.7 environment with pywin and py2exe and >> stripped down my overlay handler to the basics to better troubleshoot. >> >> Running my script (command line or in PyCharm) registers everything >> correctly, just like before, but running the py2exe generated EXE >> seems to be registering but no overlays are appearing, which looks >> just like what happens when I restarted explorer.exe in my previous >> attempt (logged messages during registration, plus a manual check of >> the registry look good but nothing generated by IsMemberOf. >> >> I'm going to try generating a DLL and manually registering following >> the example >> here: >> http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 >> >> It looks like this example came out of a mail thread with you back >> in 2011 so I'll try to follow the advice there and report back. >> >> Thanks again for the help Mark. >> >> On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond >> > wrote: >> >> On 7/01/2016 6:21 AM, Alexander Jewell wrote: >> >> Unfortunately my end goal was to bundle the entire >> application as an exe >> with PyInstaller so that the end user does not actually have >> Python >> installed. >> >> Do you think it would be possible to package the overlay >> handler in such >> a way that explorer would not need access to an installed >> Python >> interpreter? >> Embedding( >> https://docs.python.org/3.4/extending/embedding.html) >> seems >> to still require a Python interpreter but Cython sounds >> promising. >> >> >> I've used py2exe for this in the past and it works fine - you >> need to end up with a stand-alone directory that functions >> independently of any installed Python - py2exe bundles Python >> itself, pywin32, etc in just this way. Last I tried though, it >> only worked with python 2.x >> >> Mark >> >> >> -Alex >> >> On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond >> >> > >> >> wrote: >> >> My guess is that the environment (eg, PATH, PYTHONPATH >> etc) for the >> new explorer instance isn't setup correctly - how is the >> explorer.exe process started when it *does* work? It's >> hard to >> answer without more info, but Python ends up inside >> explorer.exe, so >> the environment that explorer.exe starts with is >> important. >> >> Mark >> >> On 6/01/2016 8:29 AM, Alexander Jewell wrote: >> >> So, thanks to the Tim Golden guide >> >> < >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> > >> >> ( >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> ) >> and >> other questions >> >> < >> http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python# >> > >> on >> Stack Overflow I have a script that will show >> overlays on files and >> folders based on their "state" similar to Tortoise >> SVN or >> Dropbox. Works >> great. >> >> My problem is that once I restart the explorer.exe >> process or the OS >> itself and open explorer there are no longer any >> overlays. >> >> My first thought: >> >> * Have the service that actually manages file >> state detect that no >> requests have come in and just re-register the >> overlay handler >> >> The problem here is that registration requires >> elevated permissions >> which is acceptable on initial install of the >> application by the end >> user but not every time they restart their machine. >> >> Can anyone suggest what I might be missing here? I >> have the class >> BaseOverlay and its children in a single .py file >> and register >> from my >> main app by calling this script using subprocess. >> >> >> >> |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| >> >> Is Explorer not able to re-load the script as it is >> Python? Do I >> need to >> compile into a DLL or EXE? Would that change the >> registration >> process? >> >> Here's the registration call: >> >> |win32com.server.register.UseCommandLine(BaseOverlay)| >> >> Here's the class(simplified): >> >> |classBaseOverlay:_reg_clsid_ >> ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ >> ='someoverlays'_reg_desc_ ='Icon Overlay >> Handler'_public_methods_ >> >> =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ >> >> >> =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE >> >> >> defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| >> >> Thanks for any help you can provide, >> >> Alex Jewell >> >> >> >> >> _______________________________________________ >> 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 mhammond at skippinet.com.au Tue Jan 12 18:45:24 2016 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 13 Jan 2016 10:45:24 +1100 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> <97aa2c89-6e91-d03f-94e1-48b4952e33b3@skippinet.com.au> Message-ID: <741c0f59-82e8-c3e5-0b9c-7074c6cf280e@skippinet.com.au> On 13/01/2016 6:09 AM, Alexander Jewell wrote: > I should have checked the setup file before attaching, that's actually > from a third test I ran that tried running an EXE. > In my earlier test I had create_dll = True. > During that test I ran "regsvr32 overlays.dll" (with terminal running as > Administrator) and got a success message, but no registry entries were > added and none of the logging present in the class was triggered, so it > didn't run the main method in the provided script or instantiate the class. > > Am I mistaken in thinking that regsvr32 of the DLL replaces the use of > win32com.server.register.UseCommandLine? Do I actually need both? No - the regsvr32 should be all that is necessary. Because you are in a py2exe world, the file ./py2exe/py2exe/boot_com_servers.py is used to perform the registration - some diagnostics there should help. > So I would need to: > Run the python script which writes the overlay handler GUID to the > registry and calls win32com.server.register.UseCommandLine > Run (with elevated privileges) regsvr32 to register the DLL > Restart explorer.exe process so that Explorer picks up the overlays > > Is this correct? It should be possible to do without an explicit script, executing regsvr32 in an elevated process should be all you need. I think it will also be possible to avoid restarting explorer (there's some win32com.shell function you can call IIRC) but for now, you should just focus on getting the registration working (ie, to see the registry entries being written) and then seeing your extension work when manually restarting explorer. Mark > > If so, I would have to ship both the script and the DLL build from the > script, which shouldn't be a problem; I guess I just assumed that having > two copies of the same code was incorrect. > > Thanks for bearing with me > Alex > > On Mon, Jan 11, 2016 at 5:43 PM, Mark Hammond > wrote: > > setup_2.py has: > > > setup(console=['overlays.py']) > > So that's going to create a console program with no COM support. > setup.py has: > > > # specify which type of com server you want (exe and/or dll) > > create_exe=True, > > create_dll=False > > So you are only going to get a COM object that can be created as a > .exe. Explorer wants only inproc objects (ie, those hosted in a > DLL), so you want create_dll=True and create_exe=False - you should > then get a DLL you can register with regsvr32. > > HTH, > > Mark > > > > On 12/01/2016 4:44 AM, Alexander Jewell wrote: > > Hi Mark, > > I followed your suggestion and the SO threads touching on this area. > (http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7) > Using py2exe I generated a dist folder with an exe of my overlay > script. > Running this on a machine without Python installed shows all of the > proper log messages being generated and registry entry created > for my > overlay handler, however there's no indication that explorer is > loading > and running the overlay handler. > > Following the SO examples I instead generated a COM DLL from the > same > source. I can copy this dist directory and new DLL over to a machine > without Python and use regsrv32 to register the DLL without > errors, but > it doesn't run the main method which is what sets the required > registry > entries and calls UseCommandLine so it doesn't look like it's being > registered correctly at all. > > Sorry for the newb questions, but I seem to have a big gap in my > understanding of the mechanism. > > So, the way that I'm using it at least, py2exe is either > generating an > EXE that will register correctly but not provide a COM object > with the > correct environment for explorer to run the overlay handler, or > a DLL > that should be self contained and functional but not provide the > registration functionality. > > I've attached my primary script (Overlay Handler + logging and some > helper objects) as well as 2 py2exe setup scripts I've tried. > > I'm hoping you can point out a huge flaw in my thinking, or an > obvious > step that I'm missing in the registration process. > > Thanks again for any help you can provide. > > > On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell > > >> > wrote: > > I created a fresh Python 2.7 environment with pywin and > py2exe and > stripped down my overlay handler to the basics to better > troubleshoot. > > Running my script (command line or in PyCharm) registers > everything > correctly, just like before, but running the py2exe > generated EXE > seems to be registering but no overlays are appearing, which > looks > just like what happens when I restarted explorer.exe in my > previous > attempt (logged messages during registration, plus a manual > check of > the registry look good but nothing generated by IsMemberOf. > > I'm going to try generating a DLL and manually registering > following > the example > here: > http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 > > It looks like this example came out of a mail thread with > you back > in 2011 so I'll try to follow the advice there and report back. > > Thanks again for the help Mark. > > On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond > > >> wrote: > > On 7/01/2016 6:21 AM, Alexander Jewell wrote: > > Unfortunately my end goal was to bundle the entire > application as an exe > with PyInstaller so that the end user does not > actually have > Python > installed. > > Do you think it would be possible to package the overlay > handler in such > a way that explorer would not need access to an > installed Python > interpreter? > > Embedding(https://docs.python.org/3.4/extending/embedding.html) > seems > to still require a Python interpreter but Cython sounds > promising. > > > I've used py2exe for this in the past and it works fine > - you > need to end up with a stand-alone directory that functions > independently of any installed Python - py2exe bundles > Python > itself, pywin32, etc in just this way. Last I tried > though, it > only worked with python 2.x > > Mark > > > -Alex > > On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond > > > > > > >>> wrote: > > My guess is that the environment (eg, PATH, > PYTHONPATH > etc) for the > new explorer instance isn't setup correctly - > how is the > explorer.exe process started when it *does* > work? It's > hard to > answer without more info, but Python ends up inside > explorer.exe, so > the environment that explorer.exe starts with is > important. > > Mark > > On 6/01/2016 8:29 AM, Alexander Jewell wrote: > > So, thanks to the Tim Golden guide > > > > > > (http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html) > and > other questions > > > > on > Stack Overflow I have a script that will show > overlays on files and > folders based on their "state" similar to > Tortoise > SVN or > Dropbox. Works > great. > > My problem is that once I restart the > explorer.exe > process or the OS > itself and open explorer there are no longer any > overlays. > > My first thought: > > * Have the service that actually manages file > state detect that no > requests have come in and just > re-register the > overlay handler > > The problem here is that registration requires > elevated permissions > which is acceptable on initial install of the > application by the end > user but not every time they restart their > machine. > > Can anyone suggest what I might be missing > here? I > have the class > BaseOverlay and its children in a single .py > file > and register > from my > main app by calling this script using > subprocess. > > > > |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| > > Is Explorer not able to re-load the script > as it is > Python? Do I > need to > compile into a DLL or EXE? Would that change the > registration > process? > > Here's the registration call: > > > |win32com.server.register.UseCommandLine(BaseOverlay)| > > Here's the class(simplified): > > |classBaseOverlay:_reg_clsid_ > > ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ > ='someoverlays'_reg_desc_ ='Icon Overlay > Handler'_public_methods_ > > > =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ > > > =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE > > > defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| > > Thanks for any help you can provide, > > Alex Jewell > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > > > > > >> > > https://mail.python.org/mailman/listinfo/python-win32 > > > > > > > From balexjewell at gmail.com Fri Jan 15 09:03:03 2016 From: balexjewell at gmail.com (Alexander Jewell) Date: Fri, 15 Jan 2016 09:03:03 -0500 Subject: [python-win32] Have icon overlays persist after machine restart in Python In-Reply-To: <741c0f59-82e8-c3e5-0b9c-7074c6cf280e@skippinet.com.au> References: <9ec76d92-19f2-26f7-2f7b-36253eacfc89@skippinet.com.au> <97aa2c89-6e91-d03f-94e1-48b4952e33b3@skippinet.com.au> <741c0f59-82e8-c3e5-0b9c-7074c6cf280e@skippinet.com.au> Message-ID: Thanks for the help Mark. I further stripped down my example script, removing logging and anything unnecessary. Updated the setup.py to generate the DLL and ran py2exe (with elevated perms, not sure that was necessary though). Took the dist directory generated by py2exe to another machine with no Python. >From a command prompt with elevated perms registered using regsvr32. Restarted explorer.exe manually. And overlays are working. Now I will try to slowly add back in all of the code I removed, but at least I have a base which I know works. Thanks again. On Tue, Jan 12, 2016 at 6:45 PM, Mark Hammond wrote: > On 13/01/2016 6:09 AM, Alexander Jewell wrote: > >> I should have checked the setup file before attaching, that's actually >> from a third test I ran that tried running an EXE. >> In my earlier test I had create_dll = True. >> During that test I ran "regsvr32 overlays.dll" (with terminal running as >> Administrator) and got a success message, but no registry entries were >> added and none of the logging present in the class was triggered, so it >> didn't run the main method in the provided script or instantiate the >> class. >> >> Am I mistaken in thinking that regsvr32 of the DLL replaces the use of >> win32com.server.register.UseCommandLine? Do I actually need both? >> > > No - the regsvr32 should be all that is necessary. Because you are in a > py2exe world, the file ./py2exe/py2exe/boot_com_servers.py is used to > perform the registration - some diagnostics there should help. > > So I would need to: >> Run the python script which writes the overlay handler GUID to the >> registry and calls win32com.server.register.UseCommandLine >> Run (with elevated privileges) regsvr32 to register the DLL >> Restart explorer.exe process so that Explorer picks up the overlays >> >> Is this correct? >> > > It should be possible to do without an explicit script, executing regsvr32 > in an elevated process should be all you need. I think it will also be > possible to avoid restarting explorer (there's some win32com.shell function > you can call IIRC) but for now, you should just focus on getting the > registration working (ie, to see the registry entries being written) and > then seeing your extension work when manually restarting explorer. > > Mark > > >> If so, I would have to ship both the script and the DLL build from the >> script, which shouldn't be a problem; I guess I just assumed that having >> two copies of the same code was incorrect. >> >> Thanks for bearing with me >> Alex >> >> On Mon, Jan 11, 2016 at 5:43 PM, Mark Hammond > > wrote: >> >> setup_2.py has: >> >> > setup(console=['overlays.py']) >> >> So that's going to create a console program with no COM support. >> setup.py has: >> >> > # specify which type of com server you want (exe and/or dll) >> > create_exe=True, >> > create_dll=False >> >> So you are only going to get a COM object that can be created as a >> .exe. Explorer wants only inproc objects (ie, those hosted in a >> DLL), so you want create_dll=True and create_exe=False - you should >> then get a DLL you can register with regsvr32. >> >> HTH, >> >> Mark >> >> >> >> On 12/01/2016 4:44 AM, Alexander Jewell wrote: >> >> Hi Mark, >> >> I followed your suggestion and the SO threads touching on this >> area. >> ( >> http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 >> ) >> Using py2exe I generated a dist folder with an exe of my overlay >> script. >> Running this on a machine without Python installed shows all of >> the >> proper log messages being generated and registry entry created >> for my >> overlay handler, however there's no indication that explorer is >> loading >> and running the overlay handler. >> >> Following the SO examples I instead generated a COM DLL from the >> same >> source. I can copy this dist directory and new DLL over to a >> machine >> without Python and use regsrv32 to register the DLL without >> errors, but >> it doesn't run the main method which is what sets the required >> registry >> entries and calls UseCommandLine so it doesn't look like it's >> being >> registered correctly at all. >> >> Sorry for the newb questions, but I seem to have a big gap in my >> understanding of the mechanism. >> >> So, the way that I'm using it at least, py2exe is either >> generating an >> EXE that will register correctly but not provide a COM object >> with the >> correct environment for explorer to run the overlay handler, or >> a DLL >> that should be self contained and functional but not provide the >> registration functionality. >> >> I've attached my primary script (Overlay Handler + logging and >> some >> helper objects) as well as 2 py2exe setup scripts I've tried. >> >> I'm hoping you can point out a huge flaw in my thinking, or an >> obvious >> step that I'm missing in the registration process. >> >> Thanks again for any help you can provide. >> >> >> On Fri, Jan 8, 2016 at 3:30 PM, Alexander Jewell >> >> >> >> >> wrote: >> >> I created a fresh Python 2.7 environment with pywin and >> py2exe and >> stripped down my overlay handler to the basics to better >> troubleshoot. >> >> Running my script (command line or in PyCharm) registers >> everything >> correctly, just like before, but running the py2exe >> generated EXE >> seems to be registering but no overlays are appearing, which >> looks >> just like what happens when I restarted explorer.exe in my >> previous >> attempt (logged messages during registration, plus a manual >> check of >> the registry look good but nothing generated by IsMemberOf. >> >> I'm going to try generating a DLL and manually registering >> following >> the example >> here: >> >> http://stackoverflow.com/questions/4619701/python-64-bit-dll-com-server-registration-problem-on-64-bit-windows-7 >> >> It looks like this example came out of a mail thread with >> you back >> in 2011 so I'll try to follow the advice there and report >> back. >> >> Thanks again for the help Mark. >> >> On Wed, Jan 6, 2016 at 7:19 PM, Mark Hammond >> > >> > >> >> wrote: >> >> On 7/01/2016 6:21 AM, Alexander Jewell wrote: >> >> Unfortunately my end goal was to bundle the entire >> application as an exe >> with PyInstaller so that the end user does not >> actually have >> Python >> installed. >> >> Do you think it would be possible to package the >> overlay >> handler in such >> a way that explorer would not need access to an >> installed Python >> interpreter? >> >> Embedding(https://docs.python.org/3.4/extending/embedding.html) >> seems >> to still require a Python interpreter but Cython >> sounds >> promising. >> >> >> I've used py2exe for this in the past and it works fine >> - you >> need to end up with a stand-alone directory that functions >> independently of any installed Python - py2exe bundles >> Python >> itself, pywin32, etc in just this way. Last I tried >> though, it >> only worked with python 2.x >> >> Mark >> >> >> -Alex >> >> On Wed, Jan 6, 2016 at 5:37 AM, Mark Hammond >> > >> > >> >> > >> >> > >>> wrote: >> >> My guess is that the environment (eg, PATH, >> PYTHONPATH >> etc) for the >> new explorer instance isn't setup correctly - >> how is the >> explorer.exe process started when it *does* >> work? It's >> hard to >> answer without more info, but Python ends up >> inside >> explorer.exe, so >> the environment that explorer.exe starts with is >> important. >> >> Mark >> >> On 6/01/2016 8:29 AM, Alexander Jewell wrote: >> >> So, thanks to the Tim Golden guide >> >> >> < >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> > >> >> >> ( >> http://timgolden.me.uk/python/win32_how_do_i/add-my-own-icon-overlays.html >> ) >> and >> other questions >> >> >> < >> http://stackoverflow.com/questions/4775020/icon-overlay-issue-with-python# >> > >> on >> Stack Overflow I have a script that will show >> overlays on files and >> folders based on their "state" similar to >> Tortoise >> SVN or >> Dropbox. Works >> great. >> >> My problem is that once I restart the >> explorer.exe >> process or the OS >> itself and open explorer there are no longer >> any >> overlays. >> >> My first thought: >> >> * Have the service that actually manages >> file >> state detect that no >> requests have come in and just >> re-register the >> overlay handler >> >> The problem here is that registration requires >> elevated permissions >> which is acceptable on initial install of the >> application by the end >> user but not every time they restart their >> machine. >> >> Can anyone suggest what I might be missing >> here? I >> have the class >> BaseOverlay and its children in a single .py >> file >> and register >> from my >> main app by calling this script using >> subprocess. >> >> >> >> >> |subprocess.check_call("C:\scripts\register_overlays.py",shell=True)| >> >> Is Explorer not able to re-load the script >> as it is >> Python? Do I >> need to >> compile into a DLL or EXE? Would that change >> the >> registration >> process? >> >> Here's the registration call: >> >> >> |win32com.server.register.UseCommandLine(BaseOverlay)| >> >> Here's the class(simplified): >> >> |classBaseOverlay:_reg_clsid_ >> >> ='{8D4B1C5D-F8AC-4FDA-961F-A0143CD97C41}'_reg_progid_ >> ='someoverlays'_reg_desc_ ='Icon Overlay >> Handler'_public_methods_ >> >> >> =['GetOverlayInfo','GetPriority','IsMemberOf']_com_interfaces_ >> >> >> >> =[shell.IID_IShellIconOverlayIdentifier]defGetOverlayInfo(self):returnicon_path,0,shellcon.ISIOI_ICONFILE >> >> >> >> defGetPriority(self):return50defIsMemberOf(self,fname,attributes):returnwinerror.S_OK| >> >> Thanks for any help you can provide, >> >> Alex Jewell >> >> >> >> >> >> _______________________________________________ >> 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 malte.forkel at berlin.de Sat Jan 16 14:51:50 2016 From: malte.forkel at berlin.de (Malte Forkel) Date: Sat, 16 Jan 2016 20:51:50 +0100 Subject: [python-win32] Problem registering COM server at installation time Message-ID: <569A9F56.3000002@berlin.de> Hi, I'm trying the register a COM server using the install script of a built distribution, created with the bdist_wininst format of distutils. But the script fails with a message that MSVCR90.dll can't be found. Registering the server after the installer is done works fine. I'm using Python 2.7.11 and pywin32-220 on Windows 7.1 64 bit. >From what I see in Process Monitor, I think that the search for MSVCR90.dll starts in the installer's directory, moves up the directory tree and than uses the system search path. Using Dependeny Walter (depends), I found that ''pythoncom27.dll'' and ''pywintypes27.dll'' can't locate msvcr90.dll, while pythoncomloader27.dll finds it (i.e., one of them). I tried an to import pythoncom first, hoping for some DLL magic, but that fails as well: Traceback (most recent call last): File "", line 16, in File "C:\Program Files\Python27\lib\site-packages\pythoncom.py", line 2, in import pywintypes File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in __import_pywin32_system_module__("pywintypes", globals()) File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__ raise ImportError("No system module '%s' (%s)" % (modname, filename)) ImportError: No system module 'pywintypes' (pywintypes27.dll) I'm not a Windows guy, so I'm running out of ideas what to do. Any advice? Thanks in advance, Malte From Vish.Srinivasa at elavon.com Thu Jan 21 12:27:17 2016 From: Vish.Srinivasa at elavon.com (Srinivasa, Vish) Date: Thu, 21 Jan 2016 17:27:17 +0000 Subject: [python-win32] Access Denied Message-ID: <2AA1201C0ED0A340BD96784C749D32142EDD7982@SPPATLXCHMBX01.servers.global.prv> Hello, 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:- (, 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") I deployed the service using a python wrapper. I have also deployed the said python executable using the NSSM utility with identical results. My initial reaction was it has to do with not being able to find the binaries and I added the environment variable PATH to the session thru sys.path.append(os.getenv('path')) but that didn't help. >From a profile standpoint I think it should use the default profile if I don't specify one. How do I determine what profile it is using? The user in question does not have Admin privileges and it is a domain user. I am able to open Outlook from the commandline as well with the said user credentials. A resolution to this vexing problem would be greatly appreciated. Thanks Vish Rao The information contained in this e-mail and in any attachments is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. This message has been scanned for known computer viruses. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sun Jan 24 02:44:23 2016 From: timr at probo.com (Tim Roberts) Date: Sat, 23 Jan 2016 23:44:23 -0800 Subject: [python-win32] Access Denied In-Reply-To: <2AA1201C0ED0A340BD96784C749D32142EDD7982@SPPATLXCHMBX01.servers.global.prv> References: <2AA1201C0ED0A340BD96784C749D32142EDD7982@SPPATLXCHMBX01.servers.global.prv> Message-ID: <4CCCE865-E8A0-4F93-B265-2FE4F1E4CE99@probo.com> On Jan 21, 2016, at 9:27 AM, Srinivasa, Vish > 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:- (_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 Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mbrahimi02 at gmail.com Sat Jan 30 18:31:37 2016 From: mbrahimi02 at gmail.com (Malik Brahimi) Date: Sat, 30 Jan 2016 18:31:37 -0500 Subject: [python-win32] Printer Response Message-ID: Hello, I've been looking through the win32print API but I do not believe that all the Windows features are fully exposed in this package. Is there a way for me to trigger a callback function once the print server or USB printer receives a print job such that I can obtain that print job's id? I've been asking as many people as I know and all of them have been fairly difficult in helping me solve this before my upcoming deadline. Thank you for your help and let me know if I need to clarify anything. Malik -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sun Jan 31 20:53:29 2016 From: timr at probo.com (Tim Roberts) Date: Sun, 31 Jan 2016 17:53:29 -0800 Subject: [python-win32] Printer Response In-Reply-To: References: Message-ID: <4F847881-CDEB-47DE-ACFD-587BDC22A8BA@probo.com> On Jan 30, 2016, at 3:31 PM, Malik Brahimi wrote: > > I've been looking through the win32print API but I do not believe that all the Windows features are fully exposed in this package. Is there a way for me to trigger a callback function once the print server or USB printer receives a print job such that I can obtain that print job's id? The Windows printing APIs are steeped in the mists of antiquity and mired in backward compatibility much, and are generally among the least well designed in the API set. I?m not sure what you are expecting to get. What do you think that a print job ID looks like, and what do you think you will be able to do with it? Remember that it?s quite possible to configure a Windows printer without the spooler, so that jobs go straight to the printer. In that case, there will never be an ID of any kind. You can certainly use win32print.StartDocPrinter, and that does return an identifier, but I don?t know what good that does you. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Sun Jan 31 23:42:58 2016 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 1 Feb 2016 15:42:58 +1100 Subject: [python-win32] Problem registering COM server at installation time In-Reply-To: <569A9F56.3000002@berlin.de> References: <569A9F56.3000002@berlin.de> Message-ID: <3fd7e460-7f6d-4373-368b-117569b6decf@gmail.com> On 17/01/2016 6:51 AM, Malte Forkel wrote: > Hi, > > I'm trying the register a COM server using the install script of a built > distribution, created with the bdist_wininst format of distutils. But > the script fails with a message that MSVCR90.dll can't be found. > Registering the server after the installer is done works fine. I'm using > Python 2.7.11 and pywin32-220 on Windows 7.1 64 bit. That sounds a little strange - the script should only be executed after python27.dll is loaded, which itself relies on msvcr90.dll. Does it happen to work if you put the installer executable in the same directory as python27.dll? Mark > > From what I see in Process Monitor, I think that the search for > MSVCR90.dll starts in the installer's directory, moves up the directory > tree and than uses the system search path. Using Dependeny Walter > (depends), I found that ''pythoncom27.dll'' and ''pywintypes27.dll'' > can't locate msvcr90.dll, while pythoncomloader27.dll finds it (i.e., > one of them). > > I tried an to import pythoncom first, hoping for some DLL magic, but > that fails as well: > > Traceback (most recent call last): > File "", line 16, in > File "C:\Program Files\Python27\lib\site-packages\pythoncom.py", line 2, in > import pywintypes > File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", line 124, in > __import_pywin32_system_module__("pywintypes", globals()) > File "C:\Program Files\Python27\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__ > raise ImportError("No system module '%s' (%s)" % (modname, filename)) > ImportError: No system module 'pywintypes' (pywintypes27.dll) > > I'm not a Windows guy, so I'm running out of ideas what to do. Any advice? > > Thanks in advance, > Malte > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 >