Skip to content

bpo-30374: Fixed several bugs in win_add2path.py #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

bpo-30374: Fixed several bugs in win_add2path.py #1594

wants to merge 5 commits into from

Conversation

XDcsy
Copy link

@XDcsy XDcsy commented May 15, 2017

  • Discard the DEFAULT "%PATH%" value. The system PATH is global to all users so adding "%PATH%" in user PATH is unnecessary.
  • The directory of userscripts does not exist when Python is just installed. This causes the os.path.isdir() to always return False. But it is very possible that the directory will be created later so the path should be kept there. Thus os.path.isdir() check is unnecessary and is now deleted.
  • The script compulsively sets the type of PATH var to REG_EXPAND_SZ. Now the type remains what it is. If it's REG_SZ, the %APPDATA%... path will not be added and the absolute path of it will be added instead.
  • The current script needs users to log off and then log back on to take effect. Now it takes effect immediately by broadcasting a WM_SETTINGCHANG message after the change of env vars.
  • Now displays error massages when fails to load PATH values or fails to refresh env vars.

The current script needs you to log off and then log back on to take effect.
Now it takes effect immediately by broadcasting a `WM_SETTINGCHANG` message after the change of environment variables.
@AraHaan
Copy link
Contributor

AraHaan commented May 15, 2017

Or just have the installer use an statically linked editenv library to do it all for you. That is what I do with my own pthmgr project at https://github.com/DecoraterBot-devs/pthmgr.

Although if my 'pthmgr' was part of Windows it would help with the installer and so then the installer would call the program I made. Yes, it is made using C++ and requires administrator to use but it works and broadcasts it anyway. However no version of Windows ship it and I am wiling to give the project to Microsoft or the PSF as well. However there is yet to find a way for it to hack any running instances of cmd.exe or powershell that would update the path on them without restarting it similar to how you can on Linux. If someone has an idea on that that does not require an dll injection to them to do it would help with it a lot.

* Discard the DEFAULT "%PATH%" value. The system PATH is global to all users so adding "%PATH%" in user PATH is unnecessary.
* The directory of userscripts does not exist when Python is just installed. This causes the  `os.path.isdir()` to always return False. But it is very possible that the directory will be created later so keep the path added is reasonable. Thus `os.path.isdir()` check is unnecessary and is now deleted.
* The script compulsively sets the type of PATH var to REG_EXPAND_SZ. Now the type remains what it is. If it's REG_SZ, the `%APPDATA%...` path will not be added while the other absolute paths are normally added.
* The current script needs users to log off and then log back on to take effect. Now it takes effect immediately by broadcasting a `WM_SETTINGCHANG` message after the change of env vars.
* Now displays error massages when PATH fails to load PATH values or fails to refresh env vars.
@XDcsy XDcsy changed the title bpo-30374: Refresh environment variables after adding Python to PATH bpo-30374: Fixed several bugs in win_add2path.py May 16, 2017
XDcsy added 3 commits May 16, 2017 16:38
If the type is REG_SZ, the `%APPDATA%...` path will not be added and the absolute path will be added instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants