GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-30374: Fixed several bugs in win_add2path.py by XDcsy · Pull Request #1594 · python/cpython

Conversation

@XDcsy

@XDcsy XDcsy commented May 15, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
  • 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@XDcsy
Refresh environment variables after adding Python to PATH
7659f55
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

AraHaan commented May 15, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XDcsy
Fixed several bugs
6573f5c
* 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
@XDcsy
add absolute path when type of PATH is REG_SZ
cdf93f5
If the type is REG_SZ, the `%APPDATA%...` path will not be added and the absolute path will be added instead.
@XDcsy
delete unused import
bcef92c
@XDcsy
Delete win_add2path .py
c0f9dc3
@XDcsy XDcsy closed this May 16, 2017
@neEverett neEverett mannequin mentioned this pull request Nov 30, 2022
Make win_add2path.py take effect without having to log off #74559
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@XDcsy @AraHaan
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.