labscript-suite-temp / labscript_utils

Shared modules used by the labscript suite. Includes a graphical exception handler, debug tools, configuration management, cross platform filepath conversions, unit conversions and custom GUI widgets.
Other
0 stars 0 forks source link

The Win7AppId executable can be replaced with Python calls now #22

Closed philipstarkey closed 5 years ago

philipstarkey commented 5 years ago

Original report (archived issue) by Philip Starkey (Bitbucket: pstarkey, GitHub: pstarkey).


Not sure if this has always existed, but I've discovered that the shortcut property modification done by win7appid.exe can be replicated with direct Python calls with the win32com library. For example, the below code fixes a bug with Spyder that's existed for almost 5 years which no-one bothered to solve before me:

#!python

from win32com.shell import shellcon
from win32com.propsys import propsys, pscon
import pythoncom

shortcut_path = r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)\Spyder.lnk"
store = propsys.SHGetPropertyStoreFromParsingName(shortcut_path, None, shellcon.GPS_READWRITE, propsys.IID_IPropertyStore)
store.SetValue(pscon.PKEY_AppUserModel_ID, propsys.PROPVARIANTType(u'spyder.Spyder', pythoncom.VT_LPWSTR))
store.Commit()

I'm pretty sure we should be able to do the same thing for our own shortcuts :)

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Sweet, this will be good to do at some point to stop carrying an .exe file around with us.

Nice going on fixing the spyder bug!

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


This was resolved in PR #68

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).