Skip to content

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

Closed
@philipstarkey

Description

@philipstarkey

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


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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions