Skip to content
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

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

WHYBBE
Copy link
Contributor

@WHYBBE WHYBBE commented Mar 28, 2023

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.

@niheaven
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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
Comment on lines 389 to 390
$HWND_BROADCAST = [IntPtr] 0xffff;
$WM_SETTINGCHANGE = 0x1a;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$HWND_BROADCAST = [IntPtr] 0xffff;
$WM_SETTINGCHANGE = 0x1a;
$HWND_BROADCAST = [IntPtr] 0xffff
$WM_SETTINGCHANGE = 0x1a

@chawyehsu chawyehsu merged commit bd09462 into ScoopInstaller:master Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants