From a0cdde99710f6f12eb9504bcbd3bfcbefc3ea367 Mon Sep 17 00:00:00 2001 From: coreybutler Date: Fri, 10 Dec 2021 12:19:01 -0600 Subject: [PATCH] Add alt admin check - currently removed by tree shaking, but left for reference. --- src/nvm.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/nvm.go b/src/nvm.go index 1d9b557..fede7d8 100644 --- a/src/nvm.go +++ b/src/nvm.go @@ -848,7 +848,7 @@ func runElevated(command string, forceUAC ...bool) (bool, error) { } if uac { - log.Print(command) + // Alternative elevation option at stackoverflow.com/questions/31558066/how-to-ask-for-administer-privileges-on-windows-with-go cmd := exec.Command(filepath.Join(env.root, "elevate.cmd"), command) var output bytes.Buffer var _stderr bytes.Buffer @@ -971,3 +971,13 @@ func setup() { return } } + +func isAdmin() bool { + fs, err := os.Open("\\\\.\\PHYSICALDRIVE0") + if err == nil { + fs.Close() + return true + } + + return false +}