diff --git a/internal/shell/win.go b/internal/shell/win.go index 83d3776..7bbc5aa 100644 --- a/internal/shell/win.go +++ b/internal/shell/win.go @@ -211,6 +211,12 @@ func (s *Shell) SetPath(path string) { } path = TidyWindowsPathEnv(path) + s := NewShell() + if s.KeyInfo == nil { + gprint.PrintError("Windows registry key is closed.") + return + } + oldPathValue, _, err := s.Key.GetStringValue(PathEnvName) if err != nil { gprint.PrintError("Get env $path failed: %+v", err) @@ -235,6 +241,12 @@ func (s *Shell) UnsetPath(path string) { } path = TidyWindowsPathEnv(path) + s := NewShell() + if s.KeyInfo == nil { + gprint.PrintError("Windows registry key is closed.") + return + } + oldPathValue, _, err := s.Key.GetStringValue(PathEnvName) if err != nil { gprint.PrintError("Get env $path failed: %+v", err)