diff --git a/src/nvm.go b/src/nvm.go index 2bd81800240c009f5116a74423c66ea71b54e402..ae707c0f5a2617b9efcc48345ba91677888521dc 100644 --- a/src/nvm.go +++ b/src/nvm.go @@ -340,8 +340,9 @@ func uninstall(version string) { fmt.Printf("Uninstalling node v"+version+"...") v, _ := node.GetCurrentVersion() if v == version { - cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink) - cmd.Run() + runElevated(fmt.Sprintf(`"%s" cmd /C rmdir "%s"`, + filepath.Join(env.root, "elevate.cmd"), + filepath.Clean(env.symlink))) } e := os.RemoveAll(filepath.Join(env.root, "v"+version)) if e != nil { @@ -544,8 +545,12 @@ func enable() { } func disable() { - cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), "cmd", "/C", "rmdir", env.symlink) - cmd.Run() + if !runElevated(fmt.Sprintf(`"%s" cmd /C rmdir "%s"`, + filepath.Join(env.root, "elevate.cmd"), + filepath.Clean(env.symlink))) { + return + } + fmt.Println("nvm disabled") }