[python-win32] Have icon overlays persist after machine restart in Python

Alexander Jewell balexjewell at gmail.com
Wed Jan 6 14:21:10 EST 2016


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 <skippy.hammond at gmail.com>
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: <http://mail.python.org/pipermail/python-win32/attachments/20160106/06afcafb/attachment.html>


More information about the python-win32 mailing list