On Windows, fails silently if registry key-value "...\User Shell Folders\Personal" is missing
zmic opened this issue · comments
For whatever reason, "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal" was missing on my system which causes getpath.getHomePath() to throw error.
So double-clicking the desktop icon just did nothing which was very confusing for first-time user me.
The value defaults to "%USERPROFILE%\Documents" so changing getpath.py like this fixed it for me:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyname) as k:
try:
value, type_ = winreg.QueryValueEx(k, 'Personal')
except FileNotFoundError:
value, type_ = "%USERPROFILE%\Documents", winreg.REG_EXPAND_SZ
Thanks. Having a fallback seems like an obviously good thing to have. I have added it to master now, so it should appear in the next nightly build.
Now I notice it should be r"%USERPROFILE%\Documents"
with the "r" in front to escape the backslash. Maybe you caught that.
FWIW, Windows supports the forward slash just fine. It is preferrable to use the forward slash for paths in a cross-platform context to avoid having to include unnecessary escape characters.
Is this still relevant ?