makehuman icon indicating copy to clipboard operation
makehuman copied to clipboard

On Windows, fails silently if registry key-value "...\User Shell Folders\Personal" is missing

Open zmic opened this issue 3 years ago • 4 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

zmic avatar Jul 13 '22 10:07 zmic

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.

joepal1976 avatar Jul 14 '22 07:07 joepal1976

Now I notice it should be r"%USERPROFILE%\Documents" with the "r" in front to escape the backslash. Maybe you caught that.

zmic avatar Jul 29 '22 09:07 zmic

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.

rwbaer avatar Aug 28 '22 13:08 rwbaer

Is this still relevant ?

luzpaz avatar Aug 14 '23 13:08 luzpaz

@Rob: Since this code part is windows specific, I think it's the better solution using back slashes here. But in that case we need raw strings or have to escape the back slashes. With commit a8bc2d54ff0ac92e78ff71431b1023eda42bf482 its a raw string now. Guess the issue can be closed.

Aranuvir avatar Jun 26 '24 08:06 Aranuvir