Skip to content

Commit

Permalink
Add alt admin check - currently removed by tree shaking, but left for…
Browse files Browse the repository at this point in the history
… reference.
  • Loading branch information
coreybutler committed Dec 10, 2021
1 parent 324eb6a commit a0cdde9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -971,3 +971,13 @@ func setup() {
return
}
}

func isAdmin() bool {
fs, err := os.Open("\\\\.\\PHYSICALDRIVE0")
if err == nil {
fs.Close()
return true
}

return false
}

0 comments on commit a0cdde9

Please sign in to comment.