-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
fix(install-env): Apply env immediately by SendMessageTimeout
#49
Conversation
Fix it in Scoop Core too? |
install.ps1
Outdated
@@ -401,6 +425,7 @@ function Write-Env { | |||
[Microsoft.Win32.RegistryValueKind]::String | |||
} | |||
$EnvRegisterKey.SetValue($name, $val, $RegistryValueKind) | |||
Publish-Env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be placed to two lines below? I suppose that DeleteValue
is also an action involving env modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should not be a big problem not to publish after deletion, but it will not be wrong if it is applied.
install.ps1
Outdated
$HWND_BROADCAST = [IntPtr] 0xffff; | ||
$WM_SETTINGCHANGE = 0x1a; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$HWND_BROADCAST = [IntPtr] 0xffff; | |
$WM_SETTINGCHANGE = 0x1a; | |
$HWND_BROADCAST = [IntPtr] 0xffff | |
$WM_SETTINGCHANGE = 0x1a |
Fix the problem mentioned in #48, #46, #45 mainly casued by #44.
Thanks to @chawyehsu and @r15ch13 for the information.
The information mentioned in PowerShell/PowerShell#16989#issuecomment-1364615686 is very useful, especially the last link.
Add directory to Environment PATH variable shows a method to apply env immediately, almost the same code as used in chocolatey/choco Fix: Env var changes may require reboot.
I tested the new code in several virtual machines. The env can be updated normally outside the executing process. And because the installation script will get a new env for the current session, there is no problem in using it in the current session.
However, there is no way to get it to work when using in a Windows Terminal new tab, like chawyehsu said. But restarting a Windows Terminal can solve it.